-
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
base: master
Are you sure you want to change the base?
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
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 |
|---|---|---|
|
|
@@ -67,4 +67,9 @@ protected int peerPort(final HttpExchange exchange) { | |
| protected int status(final HttpExchange exchange) { | ||
| return exchange.getResponseCode(); | ||
| } | ||
|
|
||
| @Override | ||
| protected String getRequestHeader(final HttpExchange exchange, String key) { | ||
| return exchange.getRequestHeaders().getFirst(key); | ||
|
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. ❔ question: Don't you fear we will miss header value by only taking the first one?
Contributor
Author
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 of now we expect customers to set one value per header and I honestly can't imagine people associating multiple transactions with a single http call.
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. Sure, but if you add API at the decorator level, it should be able to serve all purposes, not only the DSM one. |
||
| } | ||
| } | ||
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.