openzipkin / zipkin-gcp

Reporters and collectors for use in Google Cloud Platform
https://cloud.google.com/trace/docs/zipkin
Apache License 2.0
91 stars 54 forks source link

Spring 6 labels not translated correctly in SpanTranslator #228

Open rafal-dudek opened 1 week ago

rafal-dudek commented 1 week ago

Describe the Bug

Since Spring 6 (Spring Boot 3), it is using micrometer-observation and own classes for Observation (Tracing). In those versions the names of tags are changed.

E.g. There are labels "method" and "status": https://github.com/spring-projects/spring-framework/blob/main/spring-web/src/main/java/org/springframework/http/server/observation/ServerHttpObservationDocumentation.java#L61-L77

In Spring 5 with Sleuth/OpenTracing there were "http.method" and "http.status_code" labels: https://github.com/opentracing/opentracing-java/blob/master/opentracing-api/src/main/java/io/opentracing/tag/Tags.java#L56-L61

Zipkin-gcp provides SpanTranslator to translate those names to GCP Tracing convention: https://github.com/openzipkin/zipkin-gcp/blob/master/translation-stackdriver/src/main/java/zipkin2/translation/stackdriver/SpanTranslator.java#L27-L36

Unfortunately, it works correctly only with Spring 5 (Spring Boot 2.X) and does not translate new labels.

The result is that after updating to Spring 6 the status code and method are treated as custom labels and are not assigned to special fields "Status" and "Method" e.g. their values ​​are no longer visible in the summary table.

Expected Behaviour

SpanTranslator should translate new labels names from Spring 6.

shakuzen commented 5 days ago

Thanks for raising the issue. Since method and status are not necessarily specific to HTTP, there should probably be some additional logic to ensure the translation only happens on HTTP spans. Would anyone be willing to submit a pull request?