Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
Saving branch
  • Loading branch information
mhlidd committed Jun 27, 2025
commit 256107213f447ab92b8828b4f2550403df704316
Original file line number Diff line number Diff line change
Expand Up @@ -642,14 +642,23 @@ static ResponseHeaderTagClassifier create(AgentSpan span, Map<String, String> he

private final AgentSpan span;
private final Map<String, String> headerTags;
private final String wildcardHeaderPrefix;

public ResponseHeaderTagClassifier(AgentSpan span, Map<String, String> headerTags) {
this.span = span;
this.headerTags = headerTags;
if(headerTags.size() > 0)
System.out.println("responseHeaderTags Post-Processing\nsize: " + headerTags.size() + "; " + headerTags.keySet().toArray()[0] + " : " + headerTags.get(headerTags.keySet().toArray()[0]));
this.wildcardHeaderPrefix = this.headerTags.getOrDefault("*", null);
Comment thread
mhlidd marked this conversation as resolved.
Outdated
}

@Override
public boolean accept(String key, String value) {
System.out.println("key: " + key);
if (wildcardHeaderPrefix != null) {
System.out.println("wildcardKey: " + wildcardHeaderPrefix + key);
span.setTag(wildcardHeaderPrefix + key, value);
}
String mappedKey = headerTags.get(key.toLowerCase(Locale.ROOT));
if (mappedKey != null) {
span.setTag(mappedKey, value);
Expand Down
4 changes: 4 additions & 0 deletions internal-api/src/main/java/datadog/trace/api/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -833,12 +833,16 @@ private Config(final ConfigProvider configProvider, final InstrumenterConfig ins
logIgnoredSettingWarning(RESPONSE_HEADER_TAGS, HEADER_TAGS, ".legacy.parsing.enabled");
}
} else {
System.out.println("requestHeaderTags: ");
requestHeaderTags =
configProvider.getMergedMapWithOptionalMappings(
"http.request.headers.", true, HEADER_TAGS, REQUEST_HEADER_TAGS);
System.out.println("responseHeaderTags: ");
responseHeaderTags =
configProvider.getMergedMapWithOptionalMappings(
"http.response.headers.", true, HEADER_TAGS, RESPONSE_HEADER_TAGS);
if(responseHeaderTags.size() > 0)
System.out.println("responseHeaderTags Post-Processing\nsize: " + responseHeaderTags.size() + "; " + responseHeaderTags.keySet().toArray()[0] + " : " + responseHeaderTags.get(responseHeaderTags.keySet().toArray()[0]));
}
requestHeaderTagsCommaAllowed =
configProvider.getBoolean(REQUEST_HEADER_TAGS_COMMA_ALLOWED, true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,14 +312,20 @@ private static void loadMapWithOptionalMapping(
String value;
if (delimiter == mapPos) {
value = trimmedHeader(str, delimiter + 1, end, false);
System.out.println("delimiter==mapPos value: " + value);
// tags must start with a letter
if (!value.isEmpty() && !Character.isLetter(value.charAt(0))) {
throw new BadFormatException(
"Illegal tag starting with non letter for key '" + key + "'");
}
} else {
if(key.charAt(0) == '*'){
map.put(key, defaultPrefix);
return;
Comment thread
mcculls marked this conversation as resolved.
}
if (Character.isLetter(key.charAt(0))) {
value = defaultPrefix + Strings.normalizedHeaderTag(key);
System.out.println("else value: " + value);
} else {
// tags must start with a letter
throw new BadFormatException(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ public Map<String, String> getMergedMapWithOptionalMappings(
for (String key : keys) {
for (int i = sources.length - 1; 0 <= i; i--) {
String value = sources[i].get(key);
// System.out.println("value: " + value);
Map<String, String> parsedMap =
ConfigConverter.parseMapWithOptionalMappings(value, key, defaultPrefix, lowercaseKeys);
if (!parsedMap.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ class ConfigTest extends DDSpecification {
private static final DD_JMXFETCH_METRICS_CONFIGS_ENV = "DD_JMXFETCH_METRICS_CONFIGS"
private static final DD_TRACE_AGENT_PORT_ENV = "DD_TRACE_AGENT_PORT"
private static final DD_AGENT_PORT_LEGACY_ENV = "DD_AGENT_PORT"
private static final DD_TRACE_HEADER_TAGS = "DD_TRACE_HEADER_TAGS"
private static final DD_TRACE_REPORT_HOSTNAME = "DD_TRACE_REPORT_HOSTNAME"
private static final DD_RUNTIME_METRICS_ENABLED_ENV = "DD_RUNTIME_METRICS_ENABLED"
private static final DD_TRACE_LONG_RUNNING_ENABLED = "DD_TRACE_EXPERIMENTAL_LONG_RUNNING_ENABLED"
Expand Down Expand Up @@ -568,6 +569,7 @@ class ConfigTest extends DDSpecification {
environmentVariables.set(DD_TRACE_X_DATADOG_TAGS_MAX_LENGTH, "42")
environmentVariables.set(DD_TRACE_LONG_RUNNING_ENABLED, "true")
environmentVariables.set(DD_TRACE_LONG_RUNNING_FLUSH_INTERVAL, "81")
environmentVariables.set(DD_TRACE_HEADER_TAGS, "*")

when:
def config = new Config()
Expand All @@ -587,6 +589,7 @@ class ConfigTest extends DDSpecification {
config.xDatadogTagsMaxLength == 42
config.isLongRunningTraceEnabled()
config.getLongRunningTraceFlushInterval() == 81
config.responseHeaderTags == ["*":"http.response.headers."]
}

def "sys props override env vars"() {
Expand Down