-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
traceId, spanId not set in logs when using quartz and opentelemetry #28552
Comments
/cc @Ladicek, @brunobat, @machi1990, @mkouba, @radcortez |
I believe that this works as designed. You can't expect a I'm going to close this issue. Feel free to reopen if the paragraph above does not make any sense. |
Technically, a scheduled method can call other external services etc., and so tracing may make sense. As you mention, a scheduled method is an entrypoint, so it deserves a fresh new trace/span, I'd say. |
I see. My point was that the tracing info should not be propagated but that was probably just a misunderstanding of the problem. |
Tracing does make sense on Quartz Jobs. This is not just for HTTP. |
Thanks for adding the issue to the roadmap. However get two problem:
|
|
Without agent I don't get valid traceId, only initial values 0000000000000. So atm it's also only meant as a temp. workaround. |
We need to instrument Quartz with OpenTelemetry. Not done yet. |
moved the method with @span to a seperate service class in https://github.com/syr/quartz-otel-logs/commit/57aef0684ec3cd944d3067b4d245203b2b299e67 , but still the same spanId
|
I think we'll need a reproducer project |
See link in my previous reply. I also sent all traces to a local jaeger-aio where I saw in the jaeger UI that actually all spans were created. So it seems to me that maybe only MDC is not kept consistent. Will extend the reproducer project to verify..likely tomorrow. |
I added some log output that shows that spanId from spanContext vs. MDC is not consistent correct: logs from scheduled method (spanId in log entry is correct, but is also directly before set in MDC)
IMO not correct: logs from service method, called by scheduled method (spanId in log entries should be b6b70be685472933 as logged, because method is annotated with @WithSpan)
Maybe also another issue due to using quarkus-opentelemetry together with opentelemetry agent. |
The MDC context needs to be cleared after the job was done, with MDC.remove(...) after: |
spanId from log from testMethod keeps unchanged when I do it like this..
Only thing that worked but is cumbersome is to set also the MDC explicitly in the org.acme.quartz.TaskService#testMethod, so again like:
Which leads to correct/expected log field with new spanId and same traceId
Any idea why opentelemetry is not doing this automatically? Or is it not its responsibility? |
There is no connection between the MDC context and OpenTelemetry. |
@brunobat thank you for the clarification which brings some light in the dark and the hint about MDC.remove. Actually from my basic understanding would be easier if OTel would also set the MDC, maybe configurable by a flag. |
Or is it maybe possible to plug jboss logging to one of the logging frameworks (or vice versa) that supports automatic config of MDC (Log4J, Logback), see https://github.com/open-telemetry/opentelemetry-java-instrumentation/blob/main/docs/logger-mdc-instrumentation.md ? |
@Ladicek @brunobat @brunobat @radcortez Also having problems, as context propagation with AWS SDK seems to be not working, neither with quarkus-opentelemetry nor with the opentelemetry agent...created issue with reproducer on optentelemetry github: open-telemetry/opentelemetry-java-instrumentation#7120 without any feedback, In the meantime I wonder if I should really follow opentelemetry atm, as there are so many issues, maybe it is too new/experimental to be used. |
Hi Syr,
OpenTelemetry is constantly evolving but also needs the community contributions... |
Hi @brunobat, thanks for the info. Could you please add this list to the opentelemetry guide? IMO it's crucial to decide if the extension fits or if otel agent must be used to get more auto-instrumenation, like in our case using quartz and aws sdk libs. Might be a silly question, but is there a recommended way atm for production applications? |
OpenTelemetry tracing is not experimental anymore. We are preparing a few changes, soon, that will wide the instrumentation support. |
OK sounds good. I was referring to the status shown at code.quarkus.io.
Yes I noticed quite some issues (mainly three points in open-telemetry/opentelemetry-java-instrumentation#7120 (comment)), however it was the only way I see to get quartz and aws sdk auto-instrumented atm. We have quite few reactive code in the project, I would rather consider to change it back to impierative because there are also issues when Mutiny is combined with @transactional for example...likely mixing imperative and reactive is not a good idea. But that's another topic... |
@brunobat @Ladicek @mkouba |
I ran into the same problem, but with the simple scheduler (not quartz). Shall I open a separate issue? |
@famod yes please. |
@brunobat will do. For the simple scheduler, I've realized that a workaround seems as easy as adding |
@famod do you use otel agent or is this already working with quarkus-opentelemetry + quarkus-scheduler dependencies? Btw. I would expect this to work with simple scheduler by default opposite to the described issue here which is scoped to quartz not beeing instrumented atm. |
Is there any plan to do something similar when consuming events from Kafka? I believe it would be useful to understand the outcome of processed events. |
Not sure when this is going to be scheduled. |
IIUC, everything just works with If so, maybe we just need to add a note in the scheduler documentation instead of doing all the work to enable tracing by default for scheduled methods? |
If everything works with |
Good point |
AFAIU it does not work when using custom job classes (similar to https://quarkus.io/guides/quartz#scheduling-jobs-programmatically). Prints from job execute method (org.acme.quartz.TaskCreateJob#execute):
However, it's interesting that it works (even without
with quarkus-quartz extension. However, we need the custom job classes, so cannot use |
@syr I see that you are implementing |
@brunobat Yes, like this it's working
..but it's damn ugly. Was hoping there is a more elegant way. |
It would require adding proper OTel integration in a Would you like to try submitting a PR with the proper support? :) |
In which repo would this have to be added? opentelemetry-java-instrumentation or quarkus-opentelemetry? |
|
Gonna have a look at this |
Describe the bug
I use quarkus-quartz and quarkus-opentelemetry
Have definded a custom log format like in https://quarkus.io/guides/opentelemetry#create-the-configuration
Expected behavior
Expected that traceId etc. are filled, (this only works for rest resource), see:
Actual behavior
But for log output in quartz scheduled method everything is empty
How to Reproduce?
https://github.com/syr/quartz-otel-logs is based on latest quartz-quickstart code.
Only needs to be started, scheduler runs every 10 seconds printing log lines without traceId etc.
Calling http://localhost:8080/tasks shows that it works generally, but only for rest resources
Output of
uname -a
orver
No response
Output of
java -version
java -version openjdk version "17.0.2" 2022-01-18 OpenJDK Runtime Environment Temurin-17.0.2+8 (build 17.0.2+8) OpenJDK 64-Bit Server VM Temurin-17.0.2+8 (build 17.0.2+8, mixed mode, sharing)
GraalVM version (if different from Java)
No response
Quarkus version or git rev
2.13.2.Final
Build tool (ie. output of
mvnw --version
orgradlew --version
)Maven 3.8.1
Additional information
No response
The text was updated successfully, but these errors were encountered: