|
3 | 3 | import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.SPAN_KEY; |
4 | 4 |
|
5 | 5 | import datadog.context.Context; |
| 6 | +import datadog.context.ContextKey; |
6 | 7 | import datadog.context.ImplicitContextKeyed; |
7 | 8 | import datadog.trace.api.DDTraceId; |
8 | 9 | import datadog.trace.api.TraceConfig; |
9 | 10 | import datadog.trace.api.gateway.IGSpanInfo; |
10 | 11 | import datadog.trace.api.gateway.RequestContext; |
11 | 12 | import datadog.trace.api.interceptor.MutableSpan; |
| 13 | +import javax.annotation.Nullable; |
12 | 14 |
|
13 | | -public interface AgentSpan extends MutableSpan, ImplicitContextKeyed, IGSpanInfo, WithAgentSpan { |
| 15 | +public interface AgentSpan |
| 16 | + extends MutableSpan, ImplicitContextKeyed, Context, IGSpanInfo, WithAgentSpan { |
14 | 17 |
|
15 | 18 | DDTraceId getTraceId(); |
16 | 19 |
|
@@ -154,4 +157,16 @@ default AgentSpan asAgentSpan() { |
154 | 157 | default Context storeInto(Context context) { |
155 | 158 | return context.with(SPAN_KEY, this); |
156 | 159 | } |
| 160 | + |
| 161 | + @Nullable |
| 162 | + @Override |
| 163 | + default <T> T get(ContextKey<T> key) { |
| 164 | + // noinspection unchecked |
| 165 | + return SPAN_KEY == key ? (T) this : null; |
| 166 | + } |
| 167 | + |
| 168 | + @Override |
| 169 | + default <T> Context with(ContextKey<T> key, @Nullable T value) { |
| 170 | + return Context.root().with(SPAN_KEY, this).with(key, value); |
| 171 | + } |
157 | 172 | } |
0 commit comments