@@ -142,11 +142,9 @@ public Context extract(REQUEST_CARRIER carrier) {
142
142
public Context startSpan (REQUEST_CARRIER carrier , Context context ) {
143
143
String instrumentationName =
144
144
instrumentationNames ().length == 0 ? "http-server" : instrumentationNames ()[0 ];
145
- AgentSpanContext .Extracted spanContext = getExtractedSpanContext (context );
145
+ AgentSpanContext .Extracted extracted = callIGCallbackStart (context );
146
146
AgentSpan span =
147
- tracer ()
148
- .startSpan (instrumentationName , spanName (), callIGCallbackStart (spanContext ))
149
- .setMeasured (true );
147
+ tracer ().startSpan (instrumentationName , spanName (), extracted ).setMeasured (true );
150
148
Flow <Void > flow = callIGCallbackRequestHeaders (span , carrier );
151
149
if (flow .getAction () instanceof Flow .Action .RequestBlockingAction ) {
152
150
span .setRequestBlockingAction ((Flow .Action .RequestBlockingAction ) flow .getAction ());
@@ -158,20 +156,6 @@ public Context startSpan(REQUEST_CARRIER carrier, Context context) {
158
156
return context .with (span );
159
157
}
160
158
161
- // /**
162
- // * Use {@code startSpan(String instrumentationName, REQUEST_CARRIER carrier, Context context)}
163
- // instead.
164
- // */
165
- // @Deprecated
166
- // public Context startSpan(REQUEST_CARRIER carrier, Context context) {
167
- // return startSpan("http-server", carrier, context);
168
- // }
169
-
170
- public AgentSpanContext .Extracted getExtractedSpanContext (Context context ) {
171
- AgentSpan extractedSpan = AgentSpan .fromContext (context );
172
- return extractedSpan == null ? null : (AgentSpanContext .Extracted ) extractedSpan .context ();
173
- }
174
-
175
159
public AgentSpan onRequest (
176
160
final AgentSpan span ,
177
161
final CONNECTION connection ,
@@ -180,6 +164,11 @@ public AgentSpan onRequest(
180
164
return onRequest (span , connection , request , getExtractedSpanContext (context ));
181
165
}
182
166
167
+ public AgentSpanContext .Extracted getExtractedSpanContext (Context context ) {
168
+ AgentSpan extractedSpan = AgentSpan .fromContext (context );
169
+ return extractedSpan == null ? null : (AgentSpanContext .Extracted ) extractedSpan .context ();
170
+ }
171
+
183
172
public AgentSpan onRequest (
184
173
final AgentSpan span ,
185
174
final CONNECTION connection ,
@@ -395,22 +384,23 @@ public AgentSpan onResponse(final AgentSpan span, final RESPONSE response) {
395
384
return span ;
396
385
}
397
386
398
- private AgentSpanContext .Extracted callIGCallbackStart (final AgentSpanContext .Extracted context ) {
387
+ private AgentSpanContext .Extracted callIGCallbackStart (final Context context ) {
388
+ AgentSpanContext .Extracted extracted = getExtractedSpanContext (context );
399
389
AgentTracer .TracerAPI tracer = tracer ();
400
390
Supplier <Flow <Object >> startedCbAppSec =
401
391
tracer .getCallbackProvider (RequestContextSlot .APPSEC ).getCallback (EVENTS .requestStarted ());
402
392
Supplier <Flow <Object >> startedCbIast =
403
393
tracer .getCallbackProvider (RequestContextSlot .IAST ).getCallback (EVENTS .requestStarted ());
404
394
405
395
if (startedCbAppSec == null && startedCbIast == null ) {
406
- return context ;
396
+ return extracted ;
407
397
}
408
398
409
399
TagContext tagContext = null ;
410
- if (context == null ) {
400
+ if (extracted == null ) {
411
401
tagContext = new TagContext ();
412
- } else if (context instanceof TagContext ) {
413
- tagContext = (TagContext ) context ;
402
+ } else if (extracted instanceof TagContext ) {
403
+ tagContext = (TagContext ) extracted ;
414
404
}
415
405
416
406
if (tagContext != null ) {
@@ -423,7 +413,7 @@ private AgentSpanContext.Extracted callIGCallbackStart(final AgentSpanContext.Ex
423
413
return tagContext ;
424
414
}
425
415
426
- return context ;
416
+ return extracted ;
427
417
}
428
418
429
419
@ Override
0 commit comments