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

Not able to add custom dimensions to spanner metrics #3285

Open
siddhant16 opened this issue Aug 20, 2024 · 1 comment
Open

Not able to add custom dimensions to spanner metrics #3285

siddhant16 opened this issue Aug 20, 2024 · 1 comment
Assignees
Labels
api: spanner Issues related to the googleapis/java-spanner API. priority: p1 Important issue which blocks shipping the next release. Will be fixed prior to next release.

Comments

@siddhant16
Copy link

Hello Team,

I'm creating java-spanner client and using the PrometheusHttpServer as the metrics collector.

        PROMETHEUS_SERVER = PrometheusHttpServer.builder().setPort(portNumber).build();

I want to add custom dimensions to SDK provided metrics and for that I'm using the Resource like below,

    SpannerOptions.enableOpenTelemetryMetrics();

    Resource resource = Resource.getDefault().merge(Resource.create(Attributes.of(
        SERVICE_NAME, MY_SERVICE_NAME,
        SERVICE_VERSION, "1.0.0"
    )));

    SdkMeterProvider sdkMeterProvider =
        SdkMeterProvider.builder()
       .setResource(resource)
       .registerMetricReader(PROMETHEUS_SERVER)
       .build();

    OpenTelemetry openTelemetry =
        OpenTelemetrySdk.builder().setMeterProvider(sdkMeterProvider).build();

    optionsBuilder.setOpenTelemetry(openTelemetry);

However, when I start my application, I'm not able to see any custom dimensions attached to the SDK metrics.

# HELP spanner_get_session_timeouts_ratio_total The number of get sessions timeouts due to pool exhaustion
# TYPE spanner_get_session_timeouts_ratio_total counter
spanner_get_session_timeouts_ratio_total{client_id="client-1",database="test-db",instance_id="test-projects",otel_scope_name="cloud.google.com/java"} 0.0
# HELP spanner_gfe_header_missing_count_ratio_total Number of RPC responses received without the server-timing header, most likely means that the RPC never reached Google's network
# TYPE spanner_gfe_header_missing_count_ratio_total counter
spanner_gfe_header_missing_count_ratio_total{database="test-db",instance_id="instance-id",method="google.spanner.v1.Spanner/BatchCreateSessions",otel_scope_name="cloud.google.com/java",project_id="test-id"} 0.0
# HELP spanner_max_allowed_sessions_ratio The maximum number of sessions allowed. Configurable by the user.
# TYPE spanner_max_allowed_sessions_ratio gauge
spanner_max_allowed_sessions_ratio{{client_id="client-1",database="test-db",instance_id="test-projects",otel_scope_name="cloud.google.com/java"} 401.0
# HELP spanner_max_in_use_sessions_ratio The maximum number of sessions in use during the last 10 minute interval.
# TYPE spanner_max_in_use_sessions_ratio gauge
spanner_max_in_use_sessions_ratio{{client_id="client-1",database="test-db",instance_id="test-projects",otel_scope_name="cloud.google.com/java"} 0.0

Only I see 1 data which is not the SDK metric

# TYPE target_info gauge
target_info{service_name="my-service-name",service_version="1.0.0",telemetry_sdk_language="java",telemetry_sdk_name="opentelemetry",telemetry_sdk_version="1.41.0"} 1
@product-auto-label product-auto-label bot added the api: spanner Issues related to the googleapis/java-spanner API. label Aug 20, 2024
@rahul2393 rahul2393 added the priority: p1 Important issue which blocks shipping the next release. Will be fixed prior to next release. label Aug 22, 2024
@rahul2393
Copy link
Contributor

This is working as expected, since all the metrics exported will have your defined resource attributes (https://opentelemetry.io/docs/concepts/resources/#introduction).

Can you tell me what was your expectations? Were you expecting the attributes to be added in all the metrics?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: spanner Issues related to the googleapis/java-spanner API. priority: p1 Important issue which blocks shipping the next release. Will be fixed prior to next release.
Projects
None yet
Development

No branches or pull requests

2 participants