Jaeger sampler operation sampling strategy not working with tomcat applications #6540
Replies: 4 comments 4 replies
-
If you wish to use the span name you have to use tail based sampling (https://opentelemetry.io/docs/concepts/sampling/#tail-sampling). Samplers in java SDK use head sampling (https://opentelemetry.io/docs/concepts/sampling/#head-sampling) and can not use the span name when it changes after span creation (sampling will be done based on the name when the span was created). Alternatively instead of operation name you could use |
Beta Was this translation helpful? Give feedback.
-
I have implemented a custom Jaeger remote sampler extension to enable operation sampling for HTTP request traces originating from servers (Tomcat, Netty, etc.). ApproachThe method involves constructing the operation name in the format Additionally, the Jaeger PerOperationSampler will be updated to match HTTP path patterns instead of exact string matches to accommodate path variables in HTTP paths. For example, we can configure a sampling pattern for the operation Contribution ProposalI would like to contribute this sampler as an extension to the project: OpenTelemetry Java SDK Extensions. This sampler addresses the issue where operation-level sampling isn't functioning for HTTP requests. Implementation OptionsTo add this new sampler Simpler Approach:Add the new sampler Modular Approach:Create a new module Looking forward to your thoughts and feedback on this. |
Beta Was this translation helpful? Give feedback.
-
The contents of this repository are primary limited to things that are covered by the OTel specification. I recommend contributing this sampler to the contrib repo, rather than trying to put it into the core repository. We have very limited resources to maintain components here that are not covered by the specification. |
Beta Was this translation helpful? Give feedback.
-
Hi @jkwatson, Thank you for taking the time to review my contribution proposal. I understand that contributions should typically go into the However, I would like to highlight that the proposed If you still believe that this contribution should go into the contrib repository, I am more than willing to proceed accordingly. I wanted to ensure that I provided the full context for my initial proposal to keep this within the opentelemetry-java repository. Thank you for your guidance. |
Beta Was this translation helpful? Give feedback.
-
The Jaeger remote sampler implementation allows us to define sampling at operation name/span name. This however is not working with tomcat based applications like spring-boot applications.
As per this thread open-telemetry/opentelemetry-java-instrumentation#7853 (comment), in tomcat instrumentation, the span is started with a generic name as the route can't be determined at start of the span. Later when request processing reaches a framework where route can be determined, the name is updated with a new better name.
Since the sampling decision is made at the start of the span and tomcat span name is not known at the start, operation sampling definitions won't work for tomcat spans. For example, for a request
GET /student
, tomcat assignsHTTP GET
as the span name at start, which is then changed toGET /student
later. Sampling configurations defined for operationGET /student
won't work in this case. I observed similar behavior for Netty applications as well.Tomcat and Netty spans are generally the root spans for spring-boot web applications, which means operation/span name sampling definition isn't possible for most of the Java web applications with OpenTelemetry java agent.
Is there any alternative solution to achieve sampling at operation level for spring-boot applications?
Beta Was this translation helpful? Give feedback.
All reactions