Skip to content

Refactored requires post-processing flag #8104

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 17, 2024
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 @@ -33,7 +33,6 @@
import datadog.trace.api.internal.TraceSegment;
import datadog.trace.api.telemetry.RuleType;
import datadog.trace.api.telemetry.WafMetricCollector;
import datadog.trace.bootstrap.instrumentation.api.AgentSpan;
import datadog.trace.bootstrap.instrumentation.api.Tags;
import datadog.trace.bootstrap.instrumentation.api.URIDataAdapter;
import datadog.trace.util.stacktrace.StackTraceEvent;
Expand Down Expand Up @@ -618,18 +617,10 @@ private NoopFlow onRequestEnded(RequestContext ctx_, IGSpanInfo spanInfo) {
}
}

ctx.close(requiresPostProcessing(spanInfo));
ctx.close(spanInfo.isRequiresPostProcessing());
return NoopFlow.INSTANCE;
}

private boolean requiresPostProcessing(final IGSpanInfo spanInfo) {
if (!(spanInfo instanceof AgentSpan)) {
return true; // be conservative
}
final AgentSpan span = (AgentSpan) spanInfo;
return span.isRequiresPostProcessing();
}

private Flow<Void> onRequestHeadersDone(RequestContext ctx_) {
AppSecRequestContext ctx = ctx_.getData(RequestContextSlot.APPSEC);
if (ctx == null || ctx.isReqDataPublished()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import datadog.trace.common.writer.ddagent.PrioritizationStrategy;
import datadog.trace.core.CoreSpan;
import datadog.trace.core.DDSpan;
import datadog.trace.core.DDSpanContext;
import datadog.trace.core.monitor.HealthMetrics;
import datadog.trace.core.postprocessor.SpanPostProcessor;
import java.util.ArrayList;
Expand Down Expand Up @@ -266,8 +265,7 @@ private void maybeTracePostProcessing(List<DDSpan> trace) {
// Filter spans that need post-processing
List<DDSpan> spansToPostProcess = null;
for (DDSpan span : trace) {
DDSpanContext context = span.context();
if (context != null && context.isRequiresPostProcessing()) {
if (span.isRequiresPostProcessing()) {
if (spansToPostProcess == null) {
spansToPostProcess = new ArrayList<>();
}
Expand Down
5 changes: 5 additions & 0 deletions dd-trace-core/src/main/java/datadog/trace/core/DDSpan.java
Original file line number Diff line number Diff line change
Expand Up @@ -841,6 +841,11 @@ public boolean isRequiresPostProcessing() {
return context.isRequiresPostProcessing();
}

@Override
public void setRequiresPostProcessing(boolean requiresPostProcessing) {
context.setRequiresPostProcessing(requiresPostProcessing);
}

// to be accessible in Spock spies, which the field wouldn't otherwise be
public long getStartTimeNano() {
return startTimeNano;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,8 @@ public interface IGSpanInfo {
void setRequestBlockingAction(Flow.Action.RequestBlockingAction rba);

Flow.Action.RequestBlockingAction getRequestBlockingAction();

boolean isRequiresPostProcessing();

void setRequiresPostProcessing(boolean requiresPostProcessing);
}
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,6 @@ public interface AgentSpan extends MutableSpan, IGSpanInfo, ImplicitContextKeyed

void addLink(AgentSpanLink link);

boolean isRequiresPostProcessing();

@Override
default ScopedContext storeInto(ScopedContext context) {
return context.with(ScopedContextKey.SPAN_KEY, this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -865,6 +865,9 @@ public boolean isOutbound() {
public boolean isRequiresPostProcessing() {
return false;
}

@Override
public void setRequiresPostProcessing(boolean requiresPostProcessing) {}
}

public static final class NoopAgentScope implements AgentScope {
Expand Down
Loading