3535
3636public class TriggerProbeTest extends CapturingTestBase {
3737 private static final ProbeId TRIGGER_PROBE_ID1 = new ProbeId ("trigger probe 1" , 0 );
38+ private static final String TRIGGER_PROBE_SESSION_ID = "trigger probe sessionID" ;
3839
3940 private TestTraceInterceptor traceInterceptor ;
4041
@@ -61,7 +62,13 @@ public void cooldown() throws IOException, URISyntaxException {
6162 final String className = "com.datadog.debugger.TriggerProbe01" ;
6263 TriggerProbe probe1 =
6364 createTriggerProbe (
64- TRIGGER_PROBE_ID1 , className , "entry" , "()" , null , new Sampling (10 , 10.0 ));
65+ TRIGGER_PROBE_ID1 ,
66+ TRIGGER_PROBE_SESSION_ID ,
67+ className ,
68+ "entry" ,
69+ "()" ,
70+ null ,
71+ new Sampling (10 , 10.0 ));
6572 installProbes (
6673 Configuration .builder ()
6774 .setService (SERVICE_NAME )
@@ -75,25 +82,27 @@ public void cooldown() throws IOException, URISyntaxException {
7582
7683 assertEquals (1 , sampler .getCallCount ());
7784 List <List <? extends MutableSpan >> allTraces = traceInterceptor .getAllTraces ();
85+ assertEquals (runs , allTraces .size (), "actual traces: " + allTraces .size ());
86+
7887 long debugSessions =
7988 allTraces .stream ()
8089 .map (span -> span .get (0 ))
8190 .filter (
8291 span -> {
8392 DDSpan ddSpan = (DDSpan ) span ;
8493 PropagationTags tags = ddSpan .context ().getPropagationTags ();
85- return "1" .equals (tags .getDebugPropagation ());
94+ return ( TRIGGER_PROBE_SESSION_ID + ":1" ) .equals (tags .getDebugPropagation ());
8695 })
8796 .count ();
97+ assertEquals (1 , debugSessions , "Should only have 1 debug session. found: " + debugSessions );
98+
8899 long tagged =
89100 allTraces .stream ()
90101 .flatMap (Collection ::stream )
91102 .filter (
92103 span ->
93104 span .getTag (format ("_dd.ld.probe_id.%s" , TRIGGER_PROBE_ID1 .getId ())) != null )
94105 .count ();
95- assertEquals (runs , allTraces .size (), "actual traces: " + allTraces .size ());
96- assertEquals (1 , debugSessions , "Should only have 1 debug session. found: " + debugSessions );
97106 assertEquals (1 , tagged , "Should only have 1 tagged span. found: " + tagged );
98107 } finally {
99108 ProbeRateLimiter .setSamplerSupplier (null );
@@ -108,7 +117,14 @@ public void sampling() throws IOException, URISyntaxException {
108117
109118 final String className = "com.datadog.debugger.TriggerProbe01" ;
110119 TriggerProbe probe1 =
111- createTriggerProbe (TRIGGER_PROBE_ID1 , className , "entry" , "()" , null , new Sampling (10.0 ));
120+ createTriggerProbe (
121+ TRIGGER_PROBE_ID1 ,
122+ TRIGGER_PROBE_SESSION_ID ,
123+ className ,
124+ "entry" ,
125+ "()" ,
126+ null ,
127+ new Sampling (10.0 ));
112128 Configuration config =
113129 Configuration .builder ()
114130 .setService (SERVICE_NAME )
@@ -133,6 +149,7 @@ public void conditions() throws IOException, URISyntaxException {
133149 TriggerProbe probe1 =
134150 createTriggerProbe (
135151 TRIGGER_PROBE_ID1 ,
152+ TRIGGER_PROBE_SESSION_ID ,
136153 className ,
137154 "entry" ,
138155 "(int)" ,
@@ -155,7 +172,7 @@ public void conditions() throws IOException, URISyntaxException {
155172 span -> {
156173 DDSpan ddSpan = (DDSpan ) span ;
157174 PropagationTags tags = ddSpan .context ().getPropagationTags ();
158- return "1" .equals (tags .getDebugPropagation ());
175+ return ( TRIGGER_PROBE_SESSION_ID + ":1" ) .equals (tags .getDebugPropagation ());
159176 })
160177 .count ();
161178 assertEquals (100 , allTraces .size (), "actual traces: " + allTraces .size ());
@@ -164,13 +181,15 @@ public void conditions() throws IOException, URISyntaxException {
164181
165182 public static TriggerProbe createTriggerProbe (
166183 ProbeId id ,
184+ String sessionId ,
167185 String typeName ,
168186 String methodName ,
169187 String signature ,
170188 ProbeCondition probeCondition ,
171189 Sampling sampling ,
172190 String ... lines ) {
173191 return new TriggerProbe (id , Where .of (typeName , methodName , signature , lines ))
192+ .setSessionId (sessionId )
174193 .setProbeCondition (probeCondition )
175194 .setSampling (sampling );
176195 }
0 commit comments