-
Notifications
You must be signed in to change notification settings - Fork 324
Initial version of transactions tracking implementation for DSM #9899
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
Changes from all commits
90b21ff
2295d15
b140389
d57ec63
515f991
eb4ebb8
d27db19
1123717
135d9de
9d4b3c3
6ebc3d3
d624be7
576c9a9
184a07f
76167c9
8e40194
08c9fa9
57b1db5
d5627fd
092afea
d3fa445
7ea2ba5
d9349f3
413efac
05d730b
d0eb9ee
0fee4f2
fd4e92e
8f0855f
c6f2e64
6e626a7
7e43295
3b6e91a
155788c
2c0fa9f
9a2e80f
eedd097
d331c1f
add9a5e
ea690bd
6e55bf8
1a0d460
030b792
3ac8b1c
6b95123
1ff33bd
3ae4d74
9148b57
8d16bf5
d693055
4432903
11e76e5
ddc69bf
c48a1f8
39426c4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,6 +13,8 @@ | |
| import datadog.context.propagation.Propagators; | ||
| import datadog.trace.api.Config; | ||
| import datadog.trace.api.DDTags; | ||
| import datadog.trace.api.datastreams.DataStreamsTransactionExtractor; | ||
| import datadog.trace.api.datastreams.DataStreamsTransactionTracker; | ||
| import datadog.trace.api.function.TriConsumer; | ||
| import datadog.trace.api.function.TriFunction; | ||
| import datadog.trace.api.gateway.BlockResponseFunction; | ||
|
|
@@ -95,6 +97,14 @@ public abstract class HttpServerDecorator<REQUEST, CONNECTION, RESPONSE, REQUEST | |
|
|
||
| protected abstract int status(RESPONSE response); | ||
|
|
||
| protected String getRequestHeader(REQUEST request, String key) { | ||
| // This method was not marked as abstract in order to avoid changing all server instrumentation | ||
| // at once. | ||
| // Instead, only ones required (by DSM specifically) have it implemented. | ||
| // This can change in the future. | ||
| return null; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would be nice to have a comment why
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💭 thought: Too bad the client decorator did not follow the same conventions for http headers than url and method... no |
||
| } | ||
|
|
||
| protected String requestedSessionId(REQUEST request) { | ||
| return null; | ||
| } | ||
|
|
@@ -174,6 +184,10 @@ protected AgentSpanContext startInferredProxySpan(Context context, AgentSpanCont | |
| return span.start(extracted); | ||
| } | ||
|
|
||
| private final DataStreamsTransactionTracker.TransactionSourceReader | ||
| DSM_TRANSACTION_SOURCE_READER = | ||
| (source, headerName) -> getRequestHeader((REQUEST) source, headerName); | ||
|
|
||
| public AgentSpan onRequest( | ||
| final AgentSpan span, | ||
| final CONNECTION connection, | ||
|
|
@@ -326,6 +340,13 @@ public AgentSpan onRequest( | |
| span.setRequestBlockingAction((RequestBlockingAction) flow.getAction()); | ||
| } | ||
|
|
||
| AgentTracer.get() | ||
| .getDataStreamsMonitoring() | ||
| .trackTransaction( | ||
| span, | ||
| DataStreamsTransactionExtractor.Type.HTTP_IN_HEADERS, | ||
| request, | ||
| DSM_TRANSACTION_SOURCE_READER); | ||
| return span; | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -70,6 +70,31 @@ | |
| {"name": "toJson"} | ||
| ] | ||
| }, | ||
| { | ||
| "name" : "datadog.trace.agent.core.datastreams.DataStreamsTransactionExtractors$DataStreamsTransactionExtractorAdapter", | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As an aside, it would be nice if we generated this using annotation processing, but that's more a task for platform or SDK. |
||
| "methods": [ | ||
| {"name": "fromJson"}, | ||
| {"name": "toJson"} | ||
| ] | ||
| }, | ||
| { | ||
| "name" : "datadog.trace.agent.core.datastreams.DataStreamsTransactionExtractors$DataStreamsTransactionExtractorImpl", | ||
| "allDeclaredConstructors" : true, | ||
| "allPublicConstructors" : true, | ||
| "allDeclaredFields" : true, | ||
| "allPublicFields" : true | ||
| }, | ||
| { | ||
| "name" : "datadog.trace.api.datastreams.DataStreamsTransactionExtractor$Type", | ||
| "allDeclaredFields" : true | ||
| }, | ||
| { | ||
| "name" : "datadog.trace.agent.core.datastreams.DataStreamsTransactionExtractors$DataStreamsTransactionExtractorsAdapter", | ||
| "methods": [ | ||
| {"name": "fromJson"}, | ||
| {"name": "toJson"} | ||
| ] | ||
| }, | ||
| { | ||
| "name" : "datadog.trace.agent.core.DDSpanLink$SpanLinkAdapter", | ||
| "methods": [ | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if it's supposed to be implemented by all the server instrumentations I would rather declare the method as abstract otherwise it will be forgotten in the future by new instrumentations
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did that and then realized that every instrumentation needs to have that method implemented. Instead I went with this by default + override for servers we support in transaction tracking. I prefer to start with this and then revise / extend as needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is error prone for the next contributors that will use the API to get header values and will get
nullas if there was no header while it's due to a missing implementation.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do tend to agree. In general, I tend to strongly prefer methods be either abstract or final, so that implementors have to make a conscious choice. That said - since it just impacts DSM, I'll let DSM make the final decision.