Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ static Map<String, String> from(final Config config) {
if (config.getVersion() != null) {
context.put("version", config.getVersion());
}
// SDK identity (source.name / source.version) is emitted per-event at the top level
// (sibling of flag/variant/targeting_key), matching the flagevaluation track schema in
// logs-backend. Putting it in the batch context would map it to context.source.*, which is
// not a declared facet and causes the indexer to drop the event.
return context;
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.datadog.featureflag;

import datadog.communication.ddagent.TracerVersion;
import com.squareup.moshi.JsonAdapter;
import com.squareup.moshi.Moshi;
import com.squareup.moshi.Types;
Expand Down Expand Up @@ -157,6 +158,9 @@ private byte[] toByteArray() {
}
}

private static final String SOURCE_NAME = "dd-trace-java";
private static final String SOURCE_VERSION = TracerVersion.TRACER_VERSION;

static class FlagEvaluationEvent {
public final long timestamp;
public final FlagKeyObject flag;
Expand All @@ -168,6 +172,7 @@ static class FlagEvaluationEvent {
public final String targeting_key;
public final Boolean runtime_default_used;
public final EventContext context;
public final SourceObject source;
public final ErrorObject error;

FlagEvaluationEvent(
Expand Down Expand Up @@ -196,6 +201,7 @@ static class FlagEvaluationEvent {
(evaluationAttrs != null && !evaluationAttrs.isEmpty())
? new EventContext(evaluationAttrs)
: null;
this.source = new SourceObject(SOURCE_NAME, SOURCE_VERSION);
this.error =
(errorMessage != null && !errorMessage.isEmpty()) ? new ErrorObject(errorMessage) : null;
}
Expand Down Expand Up @@ -284,6 +290,16 @@ static class ErrorObject {
}
}

static class SourceObject {
public final String name;
public final String version;

SourceObject(final String name, final String version) {
this.name = name;
this.version = version;
}
}

static class EventContext {
public final Map<String, Object> evaluation;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import com.squareup.moshi.Moshi;
import datadog.communication.ddagent.DDAgentFeaturesDiscovery;
import datadog.communication.ddagent.SharedCommunicationObjects;
import datadog.communication.ddagent.TracerVersion;
import datadog.trace.agent.test.server.http.JavaTestHttpServer;
import datadog.trace.agent.test.server.http.JavaTestHttpServer.HandlerApi;
import datadog.trace.api.Config;
Expand Down Expand Up @@ -287,6 +288,9 @@ private static void assertContext(
assertEquals(service == null ? "unknown" : service, context.get("service"));
assertOptionalContextValue(context, "env", env);
assertOptionalContextValue(context, "version", version);
// SDK identity populated by FeatureFlagEvpContext.
assertEquals("dd-trace-java", context.get("source.name"));
assertEquals(TracerVersion.TRACER_VERSION, context.get("source.version"));
}

private static void assertOptionalContextValue(
Expand Down