1
1
package datadog .trace .civisibility .interceptor ;
2
2
3
- import datadog .trace .api .DDSpanTypes ;
3
+ import static datadog .trace .api .civisibility .CIConstants .CIAPP_TEST_ORIGIN ;
4
+
4
5
import datadog .trace .api .DDTags ;
5
6
import datadog .trace .api .interceptor .AbstractTraceInterceptor ;
6
7
import datadog .trace .api .interceptor .MutableSpan ;
7
- import datadog .trace .bootstrap .instrumentation .api .UTF8BytesString ;
8
8
import datadog .trace .core .DDSpan ;
9
9
import datadog .trace .core .DDTraceCoreInfo ;
10
10
import java .util .Collection ;
@@ -15,8 +15,6 @@ public class CiVisibilityTraceInterceptor extends AbstractTraceInterceptor {
15
15
public static final CiVisibilityTraceInterceptor INSTANCE =
16
16
new CiVisibilityTraceInterceptor (Priority .CI_VISIBILITY_TRACE );
17
17
18
- static final UTF8BytesString CIAPP_TEST_ORIGIN = UTF8BytesString .create ("ciapp-test" );
19
-
20
18
protected CiVisibilityTraceInterceptor (Priority priority ) {
21
19
super (priority );
22
20
}
@@ -33,20 +31,13 @@ public Collection<? extends MutableSpan> onTraceComplete(
33
31
34
32
final DDSpan spanToCheck = null == localRootSpan ? firstSpan : localRootSpan ;
35
33
36
- // If root span is not a CI visibility span, we drop the full trace.
37
- CharSequence type = spanToCheck .getType (); // Don't null pointer if there is no type
38
- if (type == null
39
- || (!DDSpanTypes .TEST .contentEquals (type )
40
- && !DDSpanTypes .TEST_SUITE_END .contentEquals (type )
41
- && !DDSpanTypes .TEST_MODULE_END .contentEquals (type )
42
- && !DDSpanTypes .TEST_SESSION_END .contentEquals (type ))) {
34
+ // If root span does not originate from CI visibility, we drop the full trace.
35
+ CharSequence origin = spanToCheck .getOrigin ();
36
+ if (origin == null || !CIAPP_TEST_ORIGIN .contentEquals (origin )) {
43
37
return Collections .emptyList ();
44
38
}
45
39
46
- // If the trace belongs to a "test", we need to set the origin to `ciapp-test` and the
47
- // `library_version` tag for all spans.
48
- firstSpan .context ().setOrigin (CIAPP_TEST_ORIGIN );
49
- firstSpan .setTag (DDTags .LIBRARY_VERSION_TAG_KEY , DDTraceCoreInfo .VERSION );
40
+ // If the trace belongs to a "test", we need to set the `library_version` tag for all spans.
50
41
for (MutableSpan span : trace ) {
51
42
span .setTag (DDTags .LIBRARY_VERSION_TAG_KEY , DDTraceCoreInfo .VERSION );
52
43
}
0 commit comments