Skip to content

Commit 44e8f6e

Browse files
committed
Merge branch 'main' of github.com:open-telemetry/opentelemetry-java-contrib into sdk-autoconfig
2 parents 62d41a5 + 6ff8600 commit 44e8f6e

File tree

28 files changed

+1325
-36
lines changed

28 files changed

+1325
-36
lines changed

.github/ISSUE_TEMPLATE/bug_report.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ body:
1414
- aws-xray-propagator
1515
- consistent-sampling
1616
- disk-buffering
17+
- gcp-auth-extension
18+
- gcp-resources
1719
- jfr-connection
1820
- jfr-events
1921
- jmx-metrics

.github/ISSUE_TEMPLATE/feature_request.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ body:
1414
- aws-xray-propagator
1515
- consistent-sampling
1616
- disk-buffering
17+
- gcp-auth-extension
18+
- gcp-resources
1719
- jfr-connection
1820
- jfr-events
1921
- jmx-metrics

.github/component_owners.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ components:
3333
gcp-resources:
3434
- jsuereth
3535
- psx95
36+
gcp-auth-extension:
37+
- jsuereth
38+
- psx95
3639
jfr-connection:
3740
- breedx-splk
3841
- jeanbisutti

.github/renovate.json5

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,17 @@
8787
"matchPackagePrefixes": ["jakarta.servlet:"],
8888
"matchCurrentVersion": "5.0.0",
8989
"enabled": false
90+
},
91+
{
92+
// intentionally using Spring Boot 2 in gcp-auth-extension in order to test with Java 8+
93+
"matchFileNames": [
94+
"gcp-auth-extension/build.gradle.kts"
95+
],
96+
"matchPackagePrefixes": [
97+
"org.springframework.boot"
98+
],
99+
"matchUpdateTypes": ["major"],
100+
"enabled": false,
90101
}
91102
]
92103
}

.github/scripts/draft-change-log-entries.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ component_names["compressors/"]="Compressors"
3232
component_names["consistent-sampling/"]="Consistent sampling"
3333
component_names["disk-buffering/"]="Disk buffering"
3434
component_names["gcp-resources/"]="GCP Resources"
35+
component_names["gcp-auth-extension/"]="GCP authentication extension"
3536
component_names["inferred-spans/"]="Inferred spans"
3637
component_names["jfr-connection/"]="JFR connection"
3738
component_names["jfr-events/"]="JFR events"

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ feature or via instrumentation, this project is hopefully for you.
1818
| alpha | [zstd Compressor](./compressors/compressor-zstd/README.md) |
1919
| alpha | [Consistent Sampling](./consistent-sampling/README.md) |
2020
| alpha | [Disk Buffering](./disk-buffering/README.md) |
21+
| alpha | [GCP Authentication Extension](./gcp-auth-extension/README.md) |
2122
| beta | [GCP Resources](./gcp-resources/README.md) |
2223
| beta | [Inferred Spans](./inferred-spans/README.md) |
2324
| alpha | [JFR Connection](./jfr-connection/README.md) |

buildSrc/build.gradle.kts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
plugins {
22
`kotlin-dsl`
33
// When updating, update below in dependencies too
4-
id("com.diffplug.spotless") version "6.25.0"
4+
id("com.diffplug.spotless") version "7.0.2"
55
}
66

77
repositories {
@@ -12,9 +12,9 @@ repositories {
1212

1313
dependencies {
1414
// When updating, update above in plugins too
15-
implementation("com.diffplug.spotless:spotless-plugin-gradle:6.25.0")
15+
implementation("com.diffplug.spotless:spotless-plugin-gradle:7.0.2")
1616
implementation("net.ltgt.gradle:gradle-errorprone-plugin:4.1.0")
17-
implementation("net.ltgt.gradle:gradle-nullaway-plugin:2.1.0")
17+
implementation("net.ltgt.gradle:gradle-nullaway-plugin:2.2.0")
1818
}
1919

2020
spotless {

dependencyManagement/build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ val DEPENDENCY_BOMS = listOf(
1414
"com.google.guava:guava-bom:33.4.0-jre",
1515
"com.linecorp.armeria:armeria-bom:1.31.3",
1616
"org.junit:junit-bom:5.11.4",
17-
"io.grpc:grpc-bom:1.69.0",
17+
"io.grpc:grpc-bom:1.69.1",
1818
"io.opentelemetry.instrumentation:opentelemetry-instrumentation-bom-alpha:${otelInstrumentationVersion}",
1919
"org.testcontainers:testcontainers-bom:1.20.4"
2020
)
@@ -35,7 +35,7 @@ val CORE_DEPENDENCIES = listOf(
3535
"com.google.errorprone:error_prone_annotations:${errorProneVersion}",
3636
"com.google.errorprone:error_prone_core:${errorProneVersion}",
3737
"io.github.netmikey.logunit:logunit-jul:2.0.0",
38-
"io.opentelemetry.proto:opentelemetry-proto:1.4.0-alpha",
38+
"io.opentelemetry.proto:opentelemetry-proto:1.5.0-alpha",
3939
// these two constraints can be removed once the opentelemetry-instrumentation-bom-alpha
4040
// is updated to contain the latest version of opentelemetry-semconv
4141
"io.opentelemetry.semconv:opentelemetry-semconv:${semConvVersion}",

disk-buffering/build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ plugins {
77
id("com.github.johnrengelman.shadow")
88
id("me.champeau.jmh") version "0.7.2"
99
id("ru.vyarus.animalsniffer") version "1.7.2"
10-
id("com.squareup.wire") version "5.2.0"
10+
id("com.squareup.wire") version "5.2.1"
1111
}
1212

1313
description = "Exporter implementations that store signals on disk"
@@ -53,7 +53,7 @@ wire {
5353
java {}
5454

5555
sourcePath {
56-
srcJar("io.opentelemetry.proto:opentelemetry-proto:1.4.0-alpha")
56+
srcJar("io.opentelemetry.proto:opentelemetry-proto:1.5.0-alpha")
5757
}
5858

5959
root(

gcp-auth-extension/README.md

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
# Google Cloud Authentication Extension
2+
3+
The Google Cloud Auth Extension allows the users to export telemetry from their applications to Google Cloud using the built-in OTLP exporters.\
4+
The extension takes care of the necessary configuration required to authenticate to GCP to successfully export telemetry.
5+
6+
## Prerequisites
7+
8+
### Ensure the presence of Google Cloud Credentials on your machine/environment
9+
10+
```shell
11+
gcloud auth application-default login
12+
```
13+
14+
Executing this command will save your application credentials to default path which will depend on the type of machine -
15+
16+
- Linux, macOS: `$HOME/.config/gcloud/application_default_credentials.json`
17+
- Windows: `%APPDATA%\gcloud\application_default_credentials.json`
18+
19+
**NOTE: This method of authentication is not recommended for production environments.**
20+
21+
Next, export the credentials to `GOOGLE_APPLICATION_CREDENTIALS` environment variable -
22+
23+
For Linux & MacOS:
24+
25+
```shell
26+
export GOOGLE_APPLICATION_CREDENTIALS=$HOME/.config/gcloud/application_default_credentials.json
27+
```
28+
29+
These credentials are built-in running in a Google App Engine, Google Cloud Shell or Google Compute Engine environment.
30+
31+
### Configuring the extension
32+
33+
The extension can be configured either by environment variables or system properties.
34+
35+
Here is a list of configurable options for the extension:
36+
37+
- `GOOGLE_CLOUD_PROJECT`: Environment variable that represents the Google Cloud Project ID to which the telemetry needs to be exported.
38+
- Can also be configured using `google.cloud.project` system property.
39+
- This is a required option, the agent configuration will fail if this option is not set.
40+
- `GOOGLE_CLOUD_QUOTA_PROJECT`: Environment variable that represents the Google Cloud Quota Project ID which will be charged for the GCP API usage. To learn more about a *quota project*, see [here](https://cloud.google.com/docs/quotas/quota-project).
41+
- Can also be configured using `google.cloud.quota.project` system property.
42+
- If this option is not configured, the extension will use the Quota Project ID found in the Application Default Credentials (ADC), if available. For more information on application default credentials, see [here](https://cloud.google.com/docs/authentication/application-default-credentials).
43+
44+
## Usage
45+
46+
### With OpenTelemetry Java agent
47+
48+
The OpenTelemetry Java Agent Extension can be easily added to any Java application by modifying the startup command to the application.
49+
For more information on Extensions, see the [documentation here](https://github.com/open-telemetry/opentelemetry-java-instrumentation/blob/main/examples/extension/README.md).
50+
51+
Below is a snippet showing how to add the extension to a Java application using the Gradle build system.
52+
53+
```gradle
54+
// Specify OpenTelemetry Autoinstrumentation Java Agent Path.
55+
def otelAgentPath = <OpenTelemetry Java Agent location>
56+
// Specify the path for Google Cloud Authentication Extension for the Java Agent.
57+
def extensionPath = <Google Cloud Authentication Extension location>
58+
def googleCloudProjectId = <Your Google Cloud Project ID>
59+
def googleOtlpEndpoint = <Google Cloud OTLP endpoint>
60+
61+
val autoconf_config = listOf(
62+
"-javaagent:${otelAgentPath}",
63+
"-Dotel.javaagent.extensions=${extensionPath}",
64+
// Configure the GCP Auth extension using system properties.
65+
// This can also be configured using environment variables.
66+
"-Dgoogle.cloud.project=${googleCloudProjectId}",
67+
// Configure auto instrumentation.
68+
"-Dotel.exporter.otlp.traces.endpoint=${googleOtlpEndpoint}",
69+
'-Dotel.java.global-autoconfigure.enabled=true',
70+
// Optionally enable the built-in GCP resource detector
71+
'-Dotel.resource.providers.gcp.enabled=true'
72+
'-Dotel.traces.exporter=otlp',
73+
'-Dotel.metrics.exporter=logging'
74+
)
75+
76+
application {
77+
...
78+
applicationDefaultJvmArgs = autoconf_config
79+
...
80+
}
81+
```
82+
83+
### Without OpenTelemetry Java agent
84+
85+
This extension can be used without the OpenTelemetry Java agent by leveraging the [OpenTelemetry SDK Autoconfigure](https://github.com/open-telemetry/opentelemetry-java/blob/main/sdk-extensions/autoconfigure/README.md) module.\
86+
When using the autoconfigured SDK, simply adding this extension as a dependency automatically configures authentication headers and resource attributes for spans, enabling export to Google Cloud.
87+
88+
Below is a snippet showing how to use this extension as a dependency when the application is not instrumented using the OpenTelemetry Java agent.
89+
90+
```gradle
91+
dependencies {
92+
implementation("io.opentelemetry:opentelemetry-api")
93+
implementation("io.opentelemetry:opentelemetry-sdk")
94+
implementation("io.opentelemetry:opentelemetry-exporter-otlp")
95+
implementation("io.opentelemetry:opentelemetry-sdk-extension-autoconfigure")
96+
// include the auth extension dependency
97+
implementation("io.opentelemetry.contrib:opentelemetry-gcp-auth-extension")
98+
99+
// other dependencies
100+
...
101+
102+
}
103+
104+
val autoconf_config = listOf(
105+
'-Dgoogle.cloud.project=your-gcp-project-id',
106+
'-Dotel.exporter.otlp.endpoint=https://your.otlp.endpoint:1234',
107+
'-Dotel.traces.exporter=otlp',
108+
'-Dotel.java.global-autoconfigure.enabled=true'
109+
110+
// any additional args
111+
...
112+
)
113+
114+
application {
115+
applicationDefaultJvmArgs = autoconf_config
116+
117+
// additional configuration
118+
...
119+
}
120+
```
121+
122+
## Component Owners
123+
124+
- [Josh Suereth](https://github.com/jsuereth), Google
125+
- [Pranav Sharma](https://github.com/psx95), Google
126+
127+
Learn more about component owners in [component_owners.yml](../.github/component_owners.yml).

0 commit comments

Comments
 (0)