File tree Expand file tree Collapse file tree 3 files changed +3
-11
lines changed
dd-java-agent/instrumentation/protobuf/src/main/java/datadog/trace/instrumentation/protobuf_java
main/java/datadog/trace/core/datastreams
test/groovy/datadog/trace/core/datastreams Expand file tree Collapse file tree 3 files changed +3
-11
lines changed Original file line number Diff line number Diff line change @@ -36,7 +36,7 @@ public String hierarchyMarkerType() {
3636 public ElementMatcher <TypeDescription > hierarchyMatcher () {
3737 return declaresMethod (named ("writeTo" ))
3838 .and (extendsClass (named (hierarchyMarkerType ())))
39- .and (not (nameStartsWith ("com.google.protobuf" )));
39+ .and (not (nameStartsWith ("com.google.protobuf" )). or ( named ( "com.google.protobuf.DynamicMessage" )) );
4040 }
4141
4242 @ Override
Original file line number Diff line number Diff line change @@ -13,21 +13,19 @@ public SchemaSampler() {
1313 }
1414
1515 public int trySample (long currentTimeMillis ) {
16- weight .incrementAndGet ();
1716 if (currentTimeMillis >= lastSampleMillis + SAMPLE_INTERVAL_MILLIS ) {
1817 synchronized (this ) {
1918 if (currentTimeMillis >= lastSampleMillis + SAMPLE_INTERVAL_MILLIS ) {
2019 lastSampleMillis = currentTimeMillis ;
21- int currentWeight = weight .get ();
22- weight .set (0 );
23- return currentWeight ;
20+ return weight .getAndSet (0 );
2421 }
2522 }
2623 }
2724 return 0 ;
2825 }
2926
3027 public boolean canSample (long currentTimeMillis ) {
28+ weight .incrementAndGet ();
3129 return currentTimeMillis >= lastSampleMillis + SAMPLE_INTERVAL_MILLIS ;
3230 }
3331}
Original file line number Diff line number Diff line change @@ -13,24 +13,18 @@ class SchemaSamplerTest extends DDCoreSpecification {
1313 boolean canSample1 = sampler. canSample(currentTimeMillis)
1414 int weight1 = sampler. trySample(currentTimeMillis)
1515 boolean canSample2= sampler. canSample(currentTimeMillis + 1000 )
16- int weight2 = sampler. trySample(currentTimeMillis + 1000 )
1716 boolean canSample3 = sampler. canSample(currentTimeMillis + 2000 )
18- int weight3 = sampler. trySample(currentTimeMillis + 2000 )
1917 boolean canSample4 = sampler. canSample(currentTimeMillis + 30000 )
2018 int weight4 = sampler. trySample(currentTimeMillis + 30000 )
2119 boolean canSample5 = sampler. canSample(currentTimeMillis + 30001 )
22- int weight5 = sampler. trySample(currentTimeMillis + 30001 )
2320
2421 then :
2522 canSample1
2623 weight1 == 1
2724 ! canSample2
28- weight2 == 0
2925 ! canSample3
30- weight3 == 0
3126 canSample4
3227 weight4 == 3
3328 ! canSample5
34- weight5 == 0
3529 }
3630}
You can’t perform that action at this time.
0 commit comments