Skip to content
Merged
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
Prev Previous commit
Next Next commit
compile regex
  • Loading branch information
nenadnoveljic committed Dec 3, 2024
commit cd9550f263964b9105f33b36712cc43eee787eb1
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import static datadog.trace.bootstrap.instrumentation.api.AgentTracer.activateSpan;
import static datadog.trace.bootstrap.instrumentation.api.InstrumentationTags.DBM_TRACE_INJECTED;
import static datadog.trace.bootstrap.instrumentation.api.InstrumentationTags.INSTRUMENTATION_TIME_MS;
import static datadog.trace.bootstrap.instrumentation.api.Tags.*;

import datadog.trace.api.Config;
Expand Down Expand Up @@ -29,6 +30,7 @@
import java.sql.Statement;
import java.util.HashSet;
import java.util.Set;
import java.util.regex.Pattern;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -341,8 +343,8 @@ public void setApplicationName(AgentSpan span, Connection connection) {
return;
}
final String traceParent = DECORATE.traceParent(span, priority);
if (traceParent == null
|| !traceParent.matches("^00-[a-f0-9]{32}-[a-f0-9]{16}-[a-f0-9]{2}$")) {
final Pattern pattern = Pattern.compile("^00-[a-f0-9]{32}-[a-f0-9]{16}-[a-f0-9]{2}$");
if (traceParent == null || !pattern.matcher(traceParent).matches()) {
throw new IllegalArgumentException("Invalid trace parent: " + traceParent);
Comment thread
nenadnoveljic marked this conversation as resolved.
Outdated
}
final String traceContext = "_DD_" + traceParent;
Expand All @@ -369,7 +371,7 @@ public void setApplicationName(AgentSpan span, Connection connection) {
} finally {
span.setTag(DBM_TRACE_INJECTED, true);
final long elapsed = System.currentTimeMillis() - startTime;
span.setTag("dd.instrumentation.time_ms", elapsed);
span.setTag(INSTRUMENTATION_TIME_MS, elapsed);
}
}

Expand Down