Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: enable open telemetry metrics for GRPC #2590

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

JesseLovelace
Copy link
Contributor

Enables open telemetry metrics for GRPC

Note: Currently, this emits the metrics with a "generic_task" mapping. In the future, there will be a "gcs_client" mapping supported, with more relevant attributes. We'll need to switch to that when it's available, so I've left in comments to uncomment when we make that switch

@JesseLovelace JesseLovelace requested review from a team as code owners June 17, 2024 23:00
@product-auto-label product-auto-label bot added size: l Pull request size is large. api: storage Issues related to the googleapis/java-storage API. labels Jun 17, 2024
@JesseLovelace JesseLovelace added the do not merge Indicates a pull request not ready for merge, due to either quality or timing. label Jun 18, 2024
Comment on lines 127 to 179
<!-- Open Telemetry dependencies -->
<dependency>
<groupId>io.opentelemetry</groupId>
<artifactId>opentelemetry-sdk</artifactId>
<version>1.37.0</version>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-opentelemetry</artifactId>
<version>1.64.0</version>
</dependency>
<dependency>
<groupId>io.opentelemetry</groupId>
<artifactId>opentelemetry-api</artifactId>
<version>1.37.0</version>
</dependency>

<dependency>
<groupId>io.opentelemetry</groupId>
<artifactId>opentelemetry-sdk-metrics</artifactId>
<version>1.37.0</version>
</dependency>
<dependency>
<groupId>io.opentelemetry</groupId>
<artifactId>opentelemetry-sdk-common</artifactId>
<version>1.37.0</version>
</dependency>
<dependency>
<groupId>io.opentelemetry</groupId>
<artifactId>opentelemetry-sdk-extension-autoconfigure</artifactId>
<version>1.37.0</version>
</dependency>

<dependency>
<groupId>com.google.cloud.opentelemetry</groupId>
<artifactId>detector-resources</artifactId>
<version>0.27.0-alpha</version>
</dependency>
<dependency>
<groupId>com.google.cloud.opentelemetry</groupId>
<artifactId>exporter-metrics</artifactId>
<version>0.29.0</version>
</dependency>
<dependency>
<groupId>io.opentelemetry.instrumentation</groupId>
<artifactId>opentelemetry-resources</artifactId>
<version>2.3.0-alpha</version>
</dependency>
<dependency>
<groupId>io.opentelemetry.contrib</groupId>
<artifactId>opentelemetry-gcp-resources</artifactId>
<version>1.34.0-alpha</version>
</dependency>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add all these open telemetry related dependencies into a group in the renovate config so we only get a single PR for all of them rather than a dozen? https://github.com/googleapis/java-storage/blob/main/renovate.json

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally all of the otel version come from shared dependencies. If we can't get them from shared-deps we'll need the renovate config.

Comment on lines 322 to 331
<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.opentelemetry.semconv</groupId>
<artifactId>opentelemetry-semconv</artifactId>
<version>1.25.0-alpha</version>
</dependency>
</dependencies>
</dependencyManagement>

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't listed as an actual dependency, is this needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was getting a build error without this, something about parent dependencies not resolving to the same version

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was only getting that error when trying to make a shaded jar though, so maybe it's not strictly necessary

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, that's somewhat concerning. If you get the error again, lets dig into it and see if we can suss out the conflict.

@@ -59,7 +59,7 @@

@RunWith(StorageITRunner.class)
@CrossRun(
backends = {Backend.TEST_BENCH},
backends = {Backend.PROD},
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be reverted? Looks to be a left over.

google-cloud-storage/pom.xml Outdated Show resolved Hide resolved
google-cloud-storage/pom.xml Outdated Show resolved Hide resolved
@@ -337,6 +366,215 @@ private Tuple<StorageSettings, Opts<UserProject>> resolveSettingsAndOpts() throw
return Tuple.of(builder.build(), defaultOpts);
}

private void enableGrpcMetrics(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we move all these helpers into a new class (OpenTelemetryBootstrappingUtils.java perhaps) and make them static?

GrpcOpenTelemetry.newBuilder()
.sdk(openTelemetrySdk)
.enableMetrics(
Arrays.asList(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Arrays.asList(
ImmutableList.of(

Comment on lines +165 to +169
<dependency>
<groupId>com.google.cloud.opentelemetry</groupId>
<artifactId>exporter-metrics</artifactId>
<version>0.29.0</version>
</dependency>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This artifact appears to be java11+

❯ javapMavenJars.bash com.google.cloud.opentelemetry:exporter-metrics
2024-06-18 15:40:48 com.google.cloud.opentelemetry:exporter-metrics:0.29.0
2024-06-18 15:40:48     major version: 55 // java11

Can you try to find who the maintainer is in Google and ask them if this is intentional?

The sibling artifact is java8+

❯ javapMavenJars.bash com.google.cloud.opentelemetry:detector-resources
2024-06-18 15:51:25 com.google.cloud.opentelemetry:detector-resources:0.27.0-alpha
2024-06-18 15:51:26     major version: 52 // java8

Copy link

Warning: This pull request is touching the following templated files:

  • renovate.json

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: storage Issues related to the googleapis/java-storage API. do not merge Indicates a pull request not ready for merge, due to either quality or timing. size: l Pull request size is large.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants