spring-attic / spring-cloud-gcp

Integration for Google Cloud Platform APIs with Spring
Apache License 2.0
704 stars 694 forks source link

Feature Request : avoid HealthIndicator to pull an inexistent subscription #2570

Closed olivierboudet closed 2 years ago

olivierboudet commented 3 years ago

Is your feature request related to a problem? Please describe. When using OpenTelemetry Java Instrumentation with spring-cloud-gcp, each call to /actuator/health is sampled because spans are marked as error (because my policy is to save all error traces).

image

In PubSubHealthIndicator, the check is done pulling a non-existent subscription (this.pubSubTemplate.pull("subscription-" + UUID.randomUUID().toString(), 1, true);) which logically throws a not found error. So, OpenTelemetry gRPC instrumentation catch this error and mark the span as error.

Describe the solution you'd like

Would it be possible to avoid to call a random subscription ?

meltsufin commented 3 years ago

We can certainly explore alternatives to calling a non-existent subscription, but I would also like to explore the option to tell OpenTelemetry not to trace this specific API call. Is there such a mechanism in OpenTelemetry? Maybe something like this would work?

olivierboudet commented 3 years ago

Yes, spans can be ignored in OpenTelemetry with otel.integration.grpc.enabled but it disable gRPC tracing completely (not just for health indicator)

meltsufin commented 3 years ago

Have you also looked into otel.trace.classes.exclude?

olivierboudet commented 3 years ago

I tried to set otel.trace.classes.exclude="com.google.cloud.pubsub.v1.stub.SubscriberStub" and otel.trace.classes.exclude="com.google.cloud.pubsub.v1.stub.GrpcSubscriberStub" but it does not exclude those traces.

meltsufin commented 3 years ago

Would you mind posting an issue in opentelemetry-java-instrumentation repo for this specific problem with exclusions? See: https://github.com/open-telemetry/opentelemetry-java-instrumentation/issues

elefeint commented 2 years ago

Fixed in GoogleCloudPlatform/spring-cloud-gcp#330 -- custom subscription names are now supported.