feat: Switch Eef metrics to using built in open telemetry#4385
feat: Switch Eef metrics to using built in open telemetry#4385kinsaurralde wants to merge 4 commits intogoogleapis:mainfrom
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request refactors the internal EEF metrics collection within the Spanner client library to leverage the existing built-in OpenTelemetry infrastructure. This change streamlines metric reporting by consolidating internal metrics under a unified observability framework, improving consistency and reducing the need for custom metric handling. Highlights
Changelog
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request correctly switches the EEF metrics to use the built-in OpenTelemetry instance, which is appropriate for internal metrics. The changes involve exposing the built-in OpenTelemetry instance through SpannerOptions and utilizing it in GapicSpannerRpc for the fallback channel's telemetry. Additionally, new constants and views for the EEF metrics are introduced. The implementation appears solid. I have one suggestion to enhance code maintainability by refactoring a lengthy conditional statement.
| if (!(metricData.getInstrumentationScopeInfo().getName().equals(GAX_METER_NAME) | ||
| || metricData.getInstrumentationScopeInfo().getName().equals(SPANNER_METER_NAME) | ||
| || metricData.getInstrumentationScopeInfo().getName().equals(GRPC_METER_NAME))) { | ||
| || metricData.getInstrumentationScopeInfo().getName().equals(GRPC_METER_NAME) | ||
| || metricData.getInstrumentationScopeInfo().getName().equals(GRPC_GCP_METER_NAME))) { |
There was a problem hiding this comment.
The chain of || conditions is getting long and can be hard to read. To improve readability and maintainability, consider using a Set of allowed meter names for this check.
You could define a public static Set<String> in BuiltInMetricsConstant.java:
// In BuiltInMetricsConstant.java
public static final String SPANNER_METER_NAME = "spanner-java"; // Make public
public static final String GRPC_METER_NAME = "grpc-java"; // Make public
public static final java.util.Set<String> ALLOWED_BUILT_IN_METRICS_METERS =
com.google.common.collect.ImmutableSet.of(
GAX_METER_NAME, SPANNER_METER_NAME, GRPC_METER_NAME, GRPC_GCP_METER_NAME);Then, you can simplify this check to:
if (!BuiltInMetricsConstant.ALLOWED_BUILT_IN_METRICS_METERS.contains(
metricData.getInstrumentationScopeInfo().getName())) {
// ...
}
Switching to built in open telemetry since the eef metrics are internal metrics