Skip to content
Merged
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 @@ -65,6 +65,7 @@ class TomcatServer implements WebsocketServer {
port = server.service.findConnectors()[0].localPort
assert port > 0
if (Config.get().isExperimentalPropagateProcessTagsEnabled()) {
server.getEngine().setName("tomcat")
def serverName = TraceUtils.normalizeTag(server.getEngine().getName())
assert ProcessTags.getTagsAsStringList().containsAll(["server.type:tomcat", "server.name:" + serverName])
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import com.datadog.debugger.probe.LogProbe;
import com.datadog.debugger.sink.Snapshot;
import com.squareup.moshi.JsonAdapter;
import datadog.environment.JavaVirtualMachine;
import datadog.trace.agent.test.utils.PortUtils;
import datadog.trace.bootstrap.debugger.MethodLocation;
import datadog.trace.bootstrap.debugger.ProbeId;
Expand Down Expand Up @@ -184,6 +185,9 @@ private JsonSnapshotSerializer.IntakeRequest doTestTracer(
ProcessBuilder processBuilder = createProcessBuilder(logFilePath, "--server.port=" + httpPort);
if (enableProcessTags) {
processBuilder.environment().put("DD_EXPERIMENTAL_PROPAGATE_PROCESS_TAGS_ENABLED", "true");
} else if (JavaVirtualMachine.isJavaVersion(21)) {
// disable explicitly since enable by default on 21
processBuilder.environment().put("DD_EXPERIMENTAL_PROPAGATE_PROCESS_TAGS_ENABLED", "false");
}
targetProcess = processBuilder.start();
// assert in logs app started
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import datadog.communication.monitor.Monitoring
import datadog.communication.serialization.ByteBufferConsumer
import datadog.communication.serialization.FlushingBuffer
import datadog.communication.serialization.msgpack.MsgPackWriter
import datadog.trace.api.Config
import datadog.trace.api.ProcessTags
import datadog.trace.api.StatsDClient
import datadog.trace.bootstrap.instrumentation.api.InstrumentationTags
import datadog.trace.common.sampling.RateByServiceTraceSampler
Expand Down Expand Up @@ -137,7 +139,8 @@ class DDAgentApiTest extends DDCoreSpecification {
[[buildSpan(1L, "service.name", "my-service", PropagationTags.factory().fromHeaderValue(PropagationTags.HeaderType.DATADOG, "_dd.p.usr=123"))]] | [[new TreeMap<>([
"duration" : 10,
"error" : 0,
"meta" : ["thread.name": Thread.currentThread().getName(), "_dd.p.usr": "123", "_dd.p.dm": "-1"],
"meta" : ["thread.name": Thread.currentThread().getName(), "_dd.p.usr": "123", "_dd.p.dm": "-1"] +
(Config.get().isExperimentalPropagateProcessTagsEnabled() ? ["_dd.tags.process" : ProcessTags.getTagsForSerialization().toString()] : []),
"metrics" : [
(DDSpanContext.PRIORITY_SAMPLING_KEY) : 1,
(InstrumentationTags.DD_TOP_LEVEL as String) : 1,
Expand All @@ -157,7 +160,8 @@ class DDAgentApiTest extends DDCoreSpecification {
[[buildSpan(100L, "resource.name", "my-resource", PropagationTags.factory().fromHeaderValue(PropagationTags.HeaderType.DATADOG, "_dd.p.usr=123"))]] | [[new TreeMap<>([
"duration" : 10,
"error" : 0,
"meta" : ["thread.name": Thread.currentThread().getName(), "_dd.p.usr": "123", "_dd.p.dm": "-1"],
"meta" : ["thread.name": Thread.currentThread().getName(), "_dd.p.usr": "123", "_dd.p.dm": "-1"] +
(Config.get().isExperimentalPropagateProcessTagsEnabled() ? ["_dd.tags.process" : ProcessTags.getTagsForSerialization().toString()] : []),
"metrics" : [
(DDSpanContext.PRIORITY_SAMPLING_KEY) : 1,
(InstrumentationTags.DD_TOP_LEVEL as String) : 1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ class TraceMapperV05PayloadTest extends DDSpecification {

def "body overflow causes a flush"() {
setup:
// disable process tags since they are only on the first span of the chunk otherwise the calculation woes
def hadProcessTags = Config.get().isExperimentalPropagateProcessTagsEnabled()
injectSysConfig(EXPERIMENTAL_PROPAGATE_PROCESS_TAGS_ENABLED, "false")
ProcessTags.reset()
// 4x 36 ASCII characters and 2 bytes of msgpack string prefix
int dictionarySpacePerTrace = 4 * (36 + 2)
// enough space for two traces with distinct string values, plus the header
Expand Down Expand Up @@ -78,6 +82,9 @@ class TraceMapperV05PayloadTest extends DDSpecification {
}
then:
verifier.verifyTracesConsumed()
cleanup:
injectSysConfig(EXPERIMENTAL_PROPAGATE_PROCESS_TAGS_ENABLED, Boolean.toString(hadProcessTags))
ProcessTags.reset()
}

def "test dictionary compressed traces written correctly"() {
Expand Down
3 changes: 2 additions & 1 deletion internal-api/src/main/java/datadog/trace/api/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -1508,7 +1508,8 @@ private Config(final ConfigProvider configProvider, final InstrumenterConfig ins
removeIntegrationServiceNamesEnabled =
configProvider.getBoolean(TRACE_REMOVE_INTEGRATION_SERVICE_NAMES_ENABLED, false);
experimentalPropagateProcessTagsEnabled =
configProvider.getBoolean(EXPERIMENTAL_PROPAGATE_PROCESS_TAGS_ENABLED, false);
configProvider.getBoolean(
EXPERIMENTAL_PROPAGATE_PROCESS_TAGS_ENABLED, JavaVirtualMachine.isJavaVersion(21));

peerServiceMapping = configProvider.getMergedMap(TRACE_PEER_SERVICE_MAPPING);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package datadog.trace.api

import datadog.environment.JavaVirtualMachine
import datadog.trace.api.env.CapturedEnvironment
import datadog.trace.test.util.DDSpecification

Expand Down Expand Up @@ -88,19 +89,20 @@ class ProcessTagsForkedTest extends DDSpecification {
null | "server1" | "^((?!cluster.name|server.name|server.type).)*\$"
}

def 'should not calculate process tags by default'() {
def 'should not calculate process tags by default except for java 21'() {
final boolean shouldBeEnabled = JavaVirtualMachine.isJavaVersion(21)
when:
ProcessTags.reset()
def processTags = ProcessTags.tagsForSerialization
then:
assert !ProcessTags.enabled
assert processTags == null
assert ProcessTags.enabled == shouldBeEnabled
assert (processTags != null) == shouldBeEnabled
when:
ProcessTags.addTag("test", "value")
then:
assert ProcessTags.tagsForSerialization == null
assert ProcessTags.tagsAsStringList == null
assert ProcessTags.tagsAsUTF8ByteStringList == null
assert (ProcessTags.tagsForSerialization != null) == shouldBeEnabled
assert (ProcessTags.tagsAsStringList != null) == shouldBeEnabled
assert (ProcessTags.tagsAsUTF8ByteStringList != null) == shouldBeEnabled
}

def 'should lazily recalculate when a tag is added'() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package datadog.remoteconfig

import com.squareup.moshi.Moshi
import datadog.environment.JavaVirtualMachine
import datadog.remoteconfig.tuf.RemoteConfigRequest
import datadog.trace.api.ProcessTags
import datadog.trace.bootstrap.instrumentation.api.Tags
Expand Down Expand Up @@ -58,8 +59,11 @@ class PollerRequestFactoryTest extends DDSpecification {

void 'remote config provides process tags when enabled = #enabled'() {
setup:
// to be changed when activated by default
if (enabled) {
injectSysConfig(EXPERIMENTAL_PROPAGATE_PROCESS_TAGS_ENABLED, "true")
} else if (JavaVirtualMachine.isJavaVersion(21)) {
injectSysConfig(EXPERIMENTAL_PROPAGATE_PROCESS_TAGS_ENABLED, "false")
}
ProcessTags.reset()
PollerRequestFactory factory = new PollerRequestFactory(Config.get(), TRACER_VERSION, CONTAINER_ID, ENTITY_ID, INVALID_REMOTE_CONFIG_URL, null)
Expand Down