Open ighack opened 3 years ago
@ighack This PR #6801 might be what you want.
Maybe you need the SDK.
SDK PR is currently under development, but transactionId export feature is not included. https://github.com/pinpoint-apm/pinpoint/issues/7654
@yjqg6666 The design pattern of SDK PR seems like a very good idea. A similar pattern seems to be possible with transactionid export. What do you think?
@emeroad If possible, i would prefer to migrate this feature into the official SDK. It wouldn't be hard. IMHO, the official SDK should have minimal dependency to avoid dependency conflicts and no dependency on pinpoint other modules should be recommended.
It would be so much better to get the transaction info from a stable api.
When will the SDK be released?
Working on the migration ( move application-interaction module in PR #6801 to agent-sdk). A new PR would be make in a few days later.
@ighack @ljgstudy @emeroad The feature is migrated to the PR #9175 branch. You could try it out.
Class.forName
is very performance consuming, cache the result maybe better?
@yjqg6666 I have a question, why not use a plugin to enhancement the agent sdk to set the txid in, it may be more efficient
Class.forName
is very performance consuming, cache the result maybe better?
@aalinyu Class.forName is called only 4 times per a HTTP request. According to this benchmarking, it may be not necessary.
Non-invasive implementation that does not require SDK
The current implementation has a problem of high complexity across ClassLoader, ThreadLocal, and SDK. Here are some ideas for this
ServletRequest.getAttribute()
approach
public class Sample extends HttpServlet{
protected void doGet(HttpServletRequest request, HttpServletResponse response) {
// This information is injected by the pinpoint interceptor
String transactionId = request.getAttribute("PINPOINT_TRANSACTIONID")
Long spanId = request.getAttribute("PINPOINT_SPANID")
}
}
- Pros
Simple implementation.
Simple Object Lifecycle, Easy thread propagation. Most frameworks handle propagation of request automatically.
```java
public class HttpServletRequestAdaptor implements RequestAdaptor<HttpServletRequest> {
@Override
public void setAttribute(HttpServletRequest request, String name, Object o) {
request.setAttribute(name, o);
}
}
How can I get transactionId in springboot application, like skywalking
I want to insert transactionId to mysql