dd-java-agent:1.22.0 civisibility tracing gets NPE on Karate @setup methods
Minimal setup showing issue is here: https://github.com/Cameron-Meyer/datadog-bug-demo Karate log: https://github.com/Cameron-Meyer/datadog-bug-demo/blob/master/target/karate.log
23:18:16.499 [Test worker] TRACE c.intuit.karate.core.FeatureRuntime - skipping scenario at line: 4 with tags effective: [setup]
23:18:16.505 [Test worker] TRACE com.intuit.karate - js context: org.graalvm.polyglot.Context@5d373794
23:18:16.681 [Test worker] ERROR com.intuit.karate - scenario [run] failed
java.lang.NullPointerException: Cannot invoke "datadog.trace.civisibility.DDTestSuiteImpl.testStart(String, java.lang.reflect.Method, java.lang.Long)" because "testSuite" is null
at datadog.trace.civisibility.events.TestEventsHandlerImpl.onTestStart(TestEventsHandlerImpl.java:151)
at datadog.trace.instrumentation.karate.KarateTracingHook.beforeScenario(KarateTracingHook.java:86)
at com.intuit.karate.core.ScenarioRuntime.lambda$beforeRun$1(ScenarioRuntime.java:375)
23:43:15.860 [Test worker] ERROR c.intuit.karate.core.FeatureRuntime - classpath:DisplayTheBug.feature[2:16] dynamic expression evaluation failed: karate.setup().data
Same behavior occurs with com.intuit.karate:karate-junit5 1.4.0 and 1.4.1, and with or without dd-javac-plugin(-client)
Tests pass with com.datadoghq:dd-java-agent:1.21.0 (Karate implementation was introduced 1.22.0 so makes sense, but proves it's not my karate/agent implementation)
Also created https://github.com/Cameron-Meyer/datadog-bug-demo/tree/simpler-setup to show the same behavior with much more OOTB gradle setup
Hi @Cameron-Meyer, thank you for reporting this and for the reproducer!
The fix should be out with the next tracer release, which is planned for Nov, 6th.
As a side note, there are some peculiarities in how Karate reports before/after events for the @setup scenarios that make it difficult to support tracing, so for now the fix is to disable tracing for scenarios marked with @setup, which means they will not be visible in Datadog. The scenarios that trigger the setup (the ones marked with @withSetup and @withSetupOnce in your example) will be visible, however.
Apologies for the delay, the new tracer version 1.23.0 was released yesterday. Feel free to try it out, and do let me know if the problem persists. Thanks!
Thanks for the info! Just tested it out, working perfectly!