Skip to content
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

support export trace info to app for external usage #6801

Closed
wants to merge 6 commits into from

Conversation

yjqg6666
Copy link
Contributor

@yjqg6666 yjqg6666 commented May 18, 2020

Feature

Export txId & spanId to application. Disabled by default.

Usage

If my application need to save/notify some system the txId/spanId, i could

  1. import com.navercorp.pinpoint:pinpoint-application-interaction:2.0.2 as dependency.
  2. fetch the txId/spanId

TraceInfo traceInfo = TraceInfoHolder.getTraceInfo();
String txId = TraceInfoHolder.getTransactionId();
long spanId = TraceInfoHolder.getSpanId();

Scene

In kafka lower version client/broker which do not support KAFKA header, now we could get the txId & spanId and put these info into message body, then the consumer can get the trace info and log. Now i can also save txId & my biz id(order id/user id etc) to db together.

Before this PR, we could only get the txId/spanId from slf4j.MDC in a hacky way.

@yjqg6666 yjqg6666 force-pushed the export-trace branch 2 times, most recently from a4881f9 to 01afe4e Compare May 19, 2020 02:01
@codecov-commenter
Copy link

codecov-commenter commented May 19, 2020

Codecov Report

Merging #6801 into master will decrease coverage by 0.04%.
The diff coverage is 1.08%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #6801      +/-   ##
==========================================
- Coverage   39.23%   39.18%   -0.05%     
==========================================
  Files        3195     3199       +4     
  Lines       94770    94862      +92     
  Branches    11844    11861      +17     
==========================================
- Hits        37179    37175       -4     
- Misses      54612    54706      +94     
- Partials     2979     2981       +2     
Impacted Files Coverage Δ
...int/interaction/trace/export/DefaultTraceInfo.java 0.00% <0.00%> (ø)
...nteraction/trace/export/TraceInfoExportHelper.java 0.00% <0.00%> (ø)
...oint/interaction/trace/export/TraceInfoHolder.java 0.00% <0.00%> (ø)
...rp/pinpoint/interaction/util/ClassLoaderUtils.java 0.00% <0.00%> (ø)
...p/pinpoint/bootstrap/classloader/ProfilerLibs.java 100.00% <ø> (ø)
...tstrap/agentdir/AgentDirBaseClassPathResolver.java 53.21% <ø> (ø)
...quest/ServletRequestListenerInterceptorHelper.java 57.53% <14.28%> (-4.59%) ⬇️
...p/pinpoint/rpc/client/WriteFailFutureListener.java 56.25% <0.00%> (-18.75%) ⬇️
...rc/main/java/com/navercorp/pinpoint/test/Item.java 66.66% <0.00%> (-3.34%) ⬇️
...cluster/zookeeper/ZookeeperClusterDataManager.java 52.90% <0.00%> (-1.94%) ⬇️
... and 7 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d773da8...8822907. Read the comment docs.

@emeroad
Copy link
Member

emeroad commented May 27, 2020

@yjqg6666
I have a question
If I remove pinpiont-agent in an application using export api, does it work normally?

@yjqg6666
Copy link
Contributor Author

@yjqg6666
I have a question
If I remove pinpiont-agent in an application using export api, does it work normally?

It would not affect the application, just no write only read, null TraceInfo/TransactionId would be return.

@yjqg6666
Copy link
Contributor Author

yjqg6666 commented May 27, 2020

TraceInfo traceInfo = TraceInfoHolder.getTraceInfo();
String txId = TraceInfoHolder.getTransactionId();
long spanId = TraceInfoHolder.getSpanId();

Have tested and checked that the above three variables would always be null if no pinpoint in javaagent or the request is not sampled. The package com.navercorp.pinpoint:pinpoint-application-interaction must have no extra dependency introduced.
@emeroad

@yjqg6666 yjqg6666 force-pushed the export-trace branch 2 times, most recently from af2697b to 7a30355 Compare May 28, 2020 08:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants