From 576ab8e5ca98c712706843a28f5085ad4df5b77a Mon Sep 17 00:00:00 2001 From: Stuart McCulloch Date: Thu, 28 Nov 2024 21:10:53 +0000 Subject: [PATCH] Avoids NoClassDefFoundError: Could not initialize class DDSpanLink$EncoderHolder in Graal native-image Both fromJson and toJson methods need to be registered, do the same for other JSON entries to be consistent. Also declare some JsonRule types need reflective access for a related issue using DD_TRACE_SAMPLING_RULES --- .../dd-java-agent/reflect-config.json | 24 ++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/dd-java-agent/agent-bootstrap/src/main/resources/META-INF/native-image/com.datadoghq/dd-java-agent/reflect-config.json b/dd-java-agent/agent-bootstrap/src/main/resources/META-INF/native-image/com.datadoghq/dd-java-agent/reflect-config.json index ddefd1f2561..b65c1250a5f 100644 --- a/dd-java-agent/agent-bootstrap/src/main/resources/META-INF/native-image/com.datadoghq/dd-java-agent/reflect-config.json +++ b/dd-java-agent/agent-bootstrap/src/main/resources/META-INF/native-image/com.datadoghq/dd-java-agent/reflect-config.json @@ -38,24 +38,42 @@ { "name" : "datadog.trace.agent.common.sampling.SpanSamplingRules$RuleAdapter", "methods": [ - {"name": "fromJson"} + {"name": "fromJson"}, + {"name": "toJson"} ] }, + { + "name" : "datadog.trace.agent.common.sampling.SpanSamplingRules$JsonRule", + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, { "name" : "datadog.trace.agent.common.sampling.TraceSamplingRules$RuleAdapter", "methods": [ - {"name": "fromJson"} + {"name": "fromJson"}, + {"name": "toJson"} ] }, + { + "name" : "datadog.trace.agent.common.sampling.TraceSamplingRules$JsonRule", + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, { "name" : "datadog.trace.agent.core.TracingConfigPoller$TracingSamplingRulesAdapter", "methods": [ - {"name": "fromJson"} + {"name": "fromJson"}, + {"name": "toJson"} ] }, { "name" : "datadog.trace.agent.core.DDSpanLink$SpanLinkAdapter", "methods": [ + {"name": "fromSpanLinkJson"}, {"name": "toSpanLinkJson"} ] },