Comments (7)
Definitely a bug in tracing. PR forthcoming.
from helidon.
@boris-senapt Thanks for the report.
Can you provide a simple reproducer project that shows this? If not I'll start creating one but we'd prefer one from you so we are sure we are looking at the specific problem you are.
from helidon.
@boris-senapt Thanks for the report.
Can you provide a simple reproducer project that shows this? If not I'll start creating one but we'd prefer one from you so we are sure we are looking at the specific problem you are.
Sure thing - should be able to get you a reproducer tomorrow.
from helidon.
@tjquinno I have pushed a recreate up, apologies for the delay
https://github.com/boris-senapt/helidon-trace-propagation-recreate
from helidon.
Thanks very much for the reproducer.
I am seeing what you are in the logging output but it looks to me as if the span context is being propagated properly.
I made the following small change to the pingAsync
method in PingService
to explicitly display the span and trace ID from the current context's span context, if present. (There are two added import
s not shown here):
@@ -24,7 +26,11 @@ public class PingService implements HttpService {
private void pingAsync(final ServerRequest serverRequest, final ServerResponse serverResponse) {
LOGGER.info("Async ping request received");
executor.submit(() -> {
- LOGGER.info("Running async ping request");
+ Optional<SpanContext> spanContext = Contexts.context().flatMap(c -> c.get(SpanContext.class));
+ String msg = String.format("In async ping request: span_id=%s, trace_id=%s",
+ spanContext.map(SpanContext::spanId).orElse("n/a"),
+ spanContext.map(SpanContext::traceId).orElse("n/a"));
+ LOGGER.info("Running async ping request - " + msg);
});
serverResponse.send("pong");
}
and here is the output I see:
12:52:33.165 [[0x6b79605e 0x1163ba20] WebServer socket] INFO uk.co.borismorris.PingService {span_id=3baae8fd9de6851b, trace_flags=01, trace_id=8d901da0b6aaa22dbc47a5b01c30a126} - Async ping request received
12:52:33.167 [] INFO uk.co.borismorris.PingService {} - Running async ping request - In async ping request: span_id=3baae8fd9de6851b, trace_id=8d901da0b6aaa22dbc47a5b01c30a126
12:52:33.170 [[0x6b79605e 0x1163ba20] WebServer socket] INFO io.opentelemetry.exporter.logging.LoggingSpanExporter {span_id=3baae8fd9de6851b, trace_flags=01, trace_id=8d901da0b6aaa22dbc47a5b01c30a126} - 'content-write' : 8d901da0b6aaa22dbc47a5b01c30a126 5b2216a5b39de3c1 INTERNAL [tracer: helidon-service:] {}
12:52:33.174 [[0x6b79605e 0x1163ba20] WebServer socket] INFO io.opentelemetry.exporter.logging.LoggingSpanExporter {span_id=3baae8fd9de6851b, trace_flags=01, trace_id=8d901da0b6aaa22dbc47a5b01c30a126} - 'HTTP Request' : 8d901da0b6aaa22dbc47a5b01c30a126 3baae8fd9de6851b SERVER [tracer: helidon-service:] AttributesMap{data={http.url=http://localhost:8080/ping-async, http.status_code=200, http.method=GET, http.version=1.1, component=helidon-webserver}, capacity=128, totalAddedValues=5}
Although the log message prefix from the async code does not contain the span and trace IDs the message built using the retrieved span context does show those IDs and they match the IDs logged by the code that receives the request.
Maybe the logging/MDC is not working quite correctly with the span context in this scenario.
Based on what I've seen I'm going to recategorize this as a logging issue rather than a tracing one. Someone else might carry on from here as that's not an area I'm as familiar with.
from helidon.
Interesting - so it might be that the Helidon Tracing context has kept the span in "scope" but the underlying OTEL framework hasn't; I suppose some battle of thread locals is happening.
The logging uses opentelemetry-log4j-context-data-2.17-autoconfigure
which is https://github.com/open-telemetry/opentelemetry-java-instrumentation/blob/main/instrumentation/log4j/log4j-context-data/log4j-context-data-2.17/library-autoconfigure/src/main/java/io/opentelemetry/instrumentation/log4j/contextdata/v2_17/OpenTelemetryContextDataProvider.java
This uses io.opentelemetry.context.Context.current()
to get the context - which is presumably returning empty.
The implications are a bit deeper than just logging however - the reason I came across the issue is that we use OKhttp to make calls to other services, and those calls were also losing their traces.
i.e. whilst Helidon seems to keep its SpanContext
OTEL has lost its one, and so all of the OTEL instrumentation stops working.
from helidon.
Your note sent me back to the revised test project and, while Contexts.context().get().get(SpanContext.class)
in the async code does find the correct span context there, there is no current span in scope which is undoubtedly where logging looks and probably why the propagation chain is not maintained from there forward.
More digging to do on my end.
from helidon.
Related Issues (20)
- 4.x: MP Config does not correctly handling per property overriding with config profiles HOT 1
- Weld uses synchronized in ApplicationScopedContextualInstanceStrategy, so carrier thread is pinned HOT 1
- Add support for Helidon 4 MP client and server
- Document new @ExecuteOn annotation
- [2.x] 4.x: MP `ConfigSource.getOrdinal()` always returns 100 if default ordinals are used
- [3.x] 4.x: MP `ConfigSource.getOrdinal()` always returns 100 if default ordinals are used
- Unable to compile mp-2 with native-image profile
- 4.x - native-image.properties not matching recommended layout
- 4.x - Archetype: include an SLF4J provider when SLF4J is used
- helidon-common sources JAR contains absolute paths
- Forward port of #7024 - Process tags show as span tags in Jaeger viewer with helidon-tracing-jaeger
- Heap pressure and OutOfMemory(OOM) when looking up large number of config keys HOT 8
- Platform pinning observed, potentially, indirectly caused by Helidon MP framework code (JTA) HOT 2
- [4.x] Cannot read config from environment with environment modules variables HOT 1
- 4.x: Document @MockBean unit tests
- Consider providing a GraphQL Java client
- Span listener not invoked when span is triggered by `@WithSpan` annotation or MP telemetry container or client filters
- Helidon role mapper doesn't support multiple IDCS service cells (or OIDC configs) HOT 1
- `config-metadata.json` lacks configKey for ConfiguredProviders
- Role Mapper - sensitive data in oidc-config HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from helidon.