Skip to content

Commit a9090ab

Browse files
committed
Add instrumentation config id
Same as DataDog/dd-trace-py#8783 but for Java.
1 parent e763318 commit a9090ab

File tree

3 files changed

+38
-0
lines changed

3 files changed

+38
-0
lines changed

telemetry/src/main/java/datadog/telemetry/TelemetryRequest.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,16 @@ public void writeInstallSignature() {
115115
}
116116
}
117117

118+
public void writeInstrumentationConfigId() {
119+
String instrumentationConfigId = System.getenv("DD_INSTRUMENTATION_CONFIG_ID");
120+
121+
try {
122+
requestBody.writeInstrumentationConfigId(instrumentationConfigId);
123+
} catch (IOException e) {
124+
throw new TelemetryRequestBody.SerializationException("instrumentation-config-id", e);
125+
}
126+
}
127+
118128
public void writeIntegrations() {
119129
if (!isWithinSizeLimits() || !eventSource.hasIntegrationEvent()) {
120130
return;

telemetry/src/main/java/datadog/telemetry/TelemetryRequestBody.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,13 @@ public void writeInstallSignature(String installId, String installType, String i
301301
bodyWriter.endObject();
302302
}
303303

304+
public void writeInstrumentationConfigId(String instrumentationConfigId) throws IOException {
305+
if (instrumentationConfigId == null) {
306+
return;
307+
}
308+
bodyWriter.name("instrumentation_config_id").value(instrumentationConfigId);
309+
}
310+
304311
@Nullable
305312
@Override
306313
public MediaType contentType() {

telemetry/src/test/groovy/datadog/telemetry/TelemetryServiceSpecification.groovy

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,27 @@ class TelemetryServiceSpecification extends DDSpecification {
441441
"68e75c77-57ca-4a12-adfc-575c4b05fc44" | "k8s_single_step" | "1993188215"
442442
}
443443

444+
def 'app started must have instrumentation config id'() {
445+
setup:
446+
injectEnvConfig("INSTRUMENTATION_CONFIG_ID", configId)
447+
448+
TestTelemetryRouter testHttpClient = new TestTelemetryRouter()
449+
TelemetryService telemetryService = new TelemetryService(testHttpClient, 10000, false)
450+
451+
when: 'first iteration'
452+
testHttpClient.expectRequest(TelemetryClient.Result.SUCCESS)
453+
telemetryService.sendAppStartedEvent()
454+
455+
then: 'app-started'
456+
testHttpClient.assertRequestBody(RequestType.APP_STARTED).assertPayload().installSignature(installId, installType, installTime)
457+
testHttpClient.assertNoMoreRequests()
458+
459+
where:
460+
configId
461+
null
462+
"68e75c99-57ca-4a12-adfc-575c4b05fcbe"
463+
}
464+
444465
def 'app-started must include activated products info'() {
445466
setup:
446467
injectEnvConfig(Strings.toEnvVar(AppSecConfig.APPSEC_ENABLED), appsecConfig)

0 commit comments

Comments
 (0)