-
Notifications
You must be signed in to change notification settings - Fork 292
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Reduce DSM public API and merge its extractor (#5228)
- Loading branch information
1 parent
c28320c
commit ce8a316
Showing
25 changed files
with
278 additions
and
212 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
dd-trace-core/src/main/java/datadog/trace/core/datastreams/DataStreamContextExtractor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package datadog.trace.core.datastreams; | ||
|
||
import datadog.trace.api.WellKnownTags; | ||
import datadog.trace.api.time.TimeSource; | ||
import datadog.trace.bootstrap.instrumentation.api.AgentPropagation; | ||
import datadog.trace.bootstrap.instrumentation.api.TagContext; | ||
import datadog.trace.core.propagation.HttpCodec; | ||
|
||
public class DataStreamContextExtractor implements HttpCodec.Extractor { | ||
private final HttpCodec.Extractor delegate; | ||
private final TimeSource timeSource; | ||
private final WellKnownTags wellKnownTags; | ||
|
||
public DataStreamContextExtractor( | ||
HttpCodec.Extractor extractor, TimeSource timeSource, WellKnownTags wellKnownTags) { | ||
this.delegate = extractor; | ||
this.timeSource = timeSource; | ||
this.wellKnownTags = wellKnownTags; | ||
} | ||
|
||
@Override | ||
public <C> TagContext extract(C carrier, AgentPropagation.ContextVisitor<C> getter) { | ||
// Delegate the default HTTP extraction | ||
TagContext extracted = this.delegate.extract(carrier, getter); | ||
// Extract the pathway context | ||
if (extracted != null) { | ||
DefaultPathwayContext pathwayContext = | ||
DefaultPathwayContext.extract(carrier, getter, this.timeSource, this.wellKnownTags); | ||
extracted.withPathwayContext(pathwayContext); | ||
} | ||
// Return merged extracted context | ||
return extracted; | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
dd-trace-core/src/main/java/datadog/trace/core/datastreams/DataStreamsMonitoring.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package datadog.trace.core.datastreams; | ||
|
||
import datadog.trace.api.experimental.DataStreamsContextCarrier; | ||
import datadog.trace.bootstrap.instrumentation.api.AgentDataStreamsMonitoring; | ||
import datadog.trace.bootstrap.instrumentation.api.AgentSpan; | ||
import datadog.trace.bootstrap.instrumentation.api.AgentSpan.Context; | ||
import datadog.trace.bootstrap.instrumentation.api.PathwayContext; | ||
import datadog.trace.bootstrap.instrumentation.api.StatsPoint; | ||
import datadog.trace.core.propagation.HttpCodec; | ||
|
||
public interface DataStreamsMonitoring extends AgentDataStreamsMonitoring, AutoCloseable { | ||
void start(); | ||
|
||
PathwayContext newPathwayContext(); | ||
|
||
/** | ||
* Adds DSM context extractor behavior. | ||
* | ||
* @param extractor The extractor to decorate with DSM extraction. | ||
* @return An extractor with DSM context extraction. | ||
*/ | ||
HttpCodec.Extractor decorate(HttpCodec.Extractor extractor); | ||
|
||
/** | ||
* Injects DSM {@link PathwayContext} into a span {@link Context}. | ||
* | ||
* @param span The span to update. | ||
* @param carrier The carrier of the {@link PathwayContext} to extract and inject. | ||
*/ | ||
void mergePathwayContextIntoSpan(AgentSpan span, DataStreamsContextCarrier carrier); | ||
|
||
void add(StatsPoint statsPoint); | ||
|
||
void clear(); | ||
|
||
@Override | ||
void close(); | ||
} |
Oops, something went wrong.