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 @@ -32,6 +32,7 @@
import org.openjdk.jmh.annotations.Setup;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.annotations.Warmup;
import org.openjdk.jmh.infra.Blackhole;

@State(Scope.Benchmark)
@Warmup(iterations = 4, time = 30, timeUnit = SECONDS)
Expand Down Expand Up @@ -64,8 +65,9 @@ public void setUp() {
}

@Benchmark
public AgentSpan onRequest() {
return decorator.onRequest(span, null, request, root());
public void onRequest(Blackhole bh) {
decorator.onRequest(span, null, request, root());
bh.consume(span);
}

public static class Request {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ protected boolean traceAnalyticsDefault() {
return false;
}

public AgentSpan afterStart(final AgentSpan span) {
public void afterStart(final AgentSpan span) {
if (spanType() != null) {
span.setSpanType(spanType());
}
Expand All @@ -104,64 +104,52 @@ public AgentSpan afterStart(final AgentSpan span) {

// null handled by setMetric
span.setMetric(traceAnalyticsEntry);

return span;
}

public ContextScope beforeFinish(final ContextScope scope) {
public void beforeFinish(final ContextScope scope) {
beforeFinish(scope.context());
return scope;
}

public AgentSpan beforeFinish(final AgentSpan span) {
return span;
}
public void beforeFinish(final AgentSpan span) {}

public Context beforeFinish(final Context context) {
return context;
}
public void beforeFinish(final Context context) {}

public AgentScope onError(final AgentScope scope, final Throwable throwable) {
public void onError(final AgentScope scope, final Throwable throwable) {
if (scope != null) {
onError(scope.span(), throwable);
}
return scope;
}

public AgentSpan onError(final AgentSpan span, final Throwable throwable) {
return onError(span, throwable, ErrorPriorities.DEFAULT);
public void onError(final AgentSpan span, final Throwable throwable) {
onError(span, throwable, ErrorPriorities.DEFAULT);
}

public AgentSpan onError(final AgentSpan span, final Throwable throwable, byte errorPriority) {
public void onError(final AgentSpan span, final Throwable throwable, byte errorPriority) {
if (throwable != null && span != null) {
span.addThrowable(
throwable instanceof ExecutionException ? throwable.getCause() : throwable,
errorPriority);
}
return span;
}

public ContextScope onError(final ContextScope scope, final Throwable throwable) {
public void onError(final ContextScope scope, final Throwable throwable) {
if (scope != null) {
onError(AgentSpan.fromContext(scope.context()), throwable);
}
return scope;
}

public AgentSpan onPeerConnection(
final AgentSpan span, final InetSocketAddress remoteConnection) {
public void onPeerConnection(final AgentSpan span, final InetSocketAddress remoteConnection) {
if (remoteConnection != null) {
onPeerConnection(span, remoteConnection.getAddress(), !remoteConnection.isUnresolved());
setPeerPort(span, remoteConnection.getPort());
}
return span;
}

public AgentSpan onPeerConnection(final AgentSpan span, final InetAddress remoteAddress) {
return onPeerConnection(span, remoteAddress, true);
public void onPeerConnection(final AgentSpan span, final InetAddress remoteAddress) {
onPeerConnection(span, remoteAddress, true);
}

public AgentSpan onPeerConnection(AgentSpan span, InetAddress remoteAddress, boolean resolved) {
public void onPeerConnection(AgentSpan span, InetAddress remoteAddress, boolean resolved) {
if (remoteAddress != null) {
String ip = remoteAddress.getHostAddress();
if (resolved && Config.get().isPeerHostNameEnabled()) {
Expand All @@ -173,20 +161,16 @@ public AgentSpan onPeerConnection(AgentSpan span, InetAddress remoteAddress, boo
span.setTag(Tags.PEER_HOST_IPV6, ip);
}
}
return span;
}

public AgentSpan setPeerPort(AgentSpan span, String port) {
public void setPeerPort(AgentSpan span, String port) {
span.setTag(Tags.PEER_PORT, port);

return span;
}

public AgentSpan setPeerPort(AgentSpan span, int port) {
public void setPeerPort(AgentSpan span, int port) {
if (port > UNSET_PORT) {
span.setTag(Tags.PEER_PORT, port);
}
return span;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ protected String spanKind() {
}

@Override
public AgentSpan afterStart(final AgentSpan span) {
public void afterStart(final AgentSpan span) {
final String service = service();
if (service != null) {
span.setServiceName(service, component());
Expand All @@ -41,6 +41,6 @@ public AgentSpan afterStart(final AgentSpan span) {

// Generate metrics for all client spans.
span.setMeasured(true);
return super.afterStart(span);
super.afterStart(span);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ public abstract class DBTypeProcessingDatabaseClientDecorator<CONNECTION>
extends DatabaseClientDecorator<CONNECTION> {

@Override
public AgentSpan afterStart(AgentSpan span) {
public void afterStart(AgentSpan span) {
processDatabaseType(span, dbType());
return super.afterStart(span);
super.afterStart(span);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,8 @@ public String getDbType() {
*
* @param span
* @param connection
* @return
*/
public AgentSpan onConnection(final AgentSpan span, final CONNECTION connection) {
public void onConnection(final AgentSpan span, final CONNECTION connection) {
if (connection != null) {
span.setTag(Tags.DB_USER, dbUser(connection));
onInstance(span, dbInstance(connection));
Expand All @@ -81,18 +80,16 @@ public AgentSpan onConnection(final AgentSpan span, final CONNECTION connection)
}
}
}
return span;
}

protected AgentSpan onInstance(final AgentSpan span, final String dbInstance) {
protected void onInstance(final AgentSpan span, final String dbInstance) {
if (dbInstance != null) {
span.setTag(Tags.DB_INSTANCE, dbInstance);
String serviceName = dbClientService(dbInstance);
if (null != serviceName) {
span.setServiceName(serviceName, component());
}
}
return span;
}

public String dbService(final String dbType, final String instanceName) {
Expand All @@ -114,9 +111,8 @@ public String dbClientService(final String instanceName) {
return service;
}

public AgentSpan onStatement(final AgentSpan span, final CharSequence statement) {
public void onStatement(final AgentSpan span, final CharSequence statement) {
span.setResourceName(statement);
return span;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ protected boolean shouldSetResourceName() {
}
};

public AgentSpan onRequest(final AgentSpan span, final REQUEST request) {
public void onRequest(final AgentSpan span, final REQUEST request) {
if (request != null) {
AgentTracer.get()
.getDataStreamsMonitoring()
Expand Down Expand Up @@ -143,10 +143,9 @@ public AgentSpan onRequest(final AgentSpan span, final REQUEST request) {
ssrfIastCheck(request);
}
}
return span;
}

public AgentSpan onResponse(final AgentSpan span, final RESPONSE response) {
public void onResponse(final AgentSpan span, final RESPONSE response) {
if (response != null) {
final int status = status(response);
if (status > UNSET_STATUS) {
Expand All @@ -166,7 +165,6 @@ public AgentSpan onResponse(final AgentSpan span, final RESPONSE response) {
}
}
}
return span;
}

public String operationName() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ private void resetServiceNameIfUnderInferredProxy(Context parentContext, AgentSp
}
};

public AgentSpan onRequest(
public void onRequest(
Comment thread
mcculls marked this conversation as resolved.
final AgentSpan span,
final CONNECTION connection,
final REQUEST request,
Expand Down Expand Up @@ -428,7 +428,6 @@ public AgentSpan onRequest(
DataStreamsTransactionExtractor.Type.HTTP_IN_HEADERS,
request,
DSM_TRANSACTION_SOURCE_READER);
return span;
}

protected static AgentSpanContext.Extracted getExtractedSpanContext(Context parentContext) {
Expand All @@ -449,7 +448,7 @@ protected BlockResponseFunction createBlockResponseFunction(
return null;
}

public AgentSpan onResponseStatus(final AgentSpan span, final int status) {
public void onResponseStatus(final AgentSpan span, final int status) {
if (status > UNSET_STATUS) {
span.setHttpStatusCode(status);
// explicitly set here because some other decorators might already set an error without
Expand All @@ -465,7 +464,6 @@ public AgentSpan onResponseStatus(final AgentSpan span, final int status) {
if (SHOULD_SET_404_RESOURCE_NAME && status == 404) {
span.setResourceName(NOT_FOUND_RESOURCE_NAME, ResourceNamePriorities.HTTP_404);
}
return span;
}

/**
Expand All @@ -483,7 +481,7 @@ protected boolean isAppSecOnResponseSeparate() {
return false;
}

public AgentSpan onResponse(final AgentSpan span, final RESPONSE response) {
public void onResponse(final AgentSpan span, final RESPONSE response) {
if (response != null) {
final int status = status(response);
onResponseStatus(span, status);
Expand All @@ -501,7 +499,6 @@ public AgentSpan onResponse(final AgentSpan span, final RESPONSE response) {
callIGCallbackResponseAndHeaders(span, response, status);
}
}
return span;
}

private AgentSpanContext callIGCallbackStart(@Nullable final AgentSpanContext extracted) {
Expand Down Expand Up @@ -536,13 +533,12 @@ private AgentSpanContext callIGCallbackStart(@Nullable final AgentSpanContext ex
}

@Override
public AgentSpan onError(final AgentSpan span, final Throwable throwable) {
public void onError(final AgentSpan span, final Throwable throwable) {
if (throwable != null) {
span.addThrowable(
throwable instanceof ExecutionException ? throwable.getCause() : throwable,
ErrorPriorities.HTTP_SERVER_DECORATOR);
}
return span;
}

private Flow<Void> callIGCallbackRequestHeaders(AgentSpan span, REQUEST_CARRIER carrier) {
Expand Down Expand Up @@ -639,7 +635,7 @@ private Flow<Void> callIGCallbackURI(
}

@Override
public Context beforeFinish(Context context) {
public void beforeFinish(Context context) {
AgentSpan span = AgentSpan.fromContext(context);
if (span != null) {
onRequestEndForInstrumentationGateway(span);
Expand All @@ -648,7 +644,7 @@ public Context beforeFinish(Context context) {
// Close Serverless Gateway Inferred Span if any
finishInferredProxySpan(context);

return super.beforeFinish(context);
super.beforeFinish(context);
}

protected void finishInferredProxySpan(Context context) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ protected boolean endToEndDurationsDefault() {
}

@Override
public AgentSpan afterStart(final AgentSpan span) {
public void afterStart(final AgentSpan span) {
if (endToEndDurationsEnabled) {
span.beginEndToEnd();
}
return super.afterStart(span);
super.afterStart(span);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,12 @@ public abstract class OrmClientDecorator extends DatabaseClientDecorator {

public abstract CharSequence entityName(final Object entity);

public AgentSpan onOperation(final AgentSpan span, final Object entity) {
public void onOperation(final AgentSpan span, final Object entity) {
if (entity != null) {
final CharSequence name = entityName(entity);
if (name != null) {
span.setResourceName(name);
} // else we keep any existing resource.
}
return span;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ public abstract class ServerDecorator extends BaseDecorator {
TagMap.Entry.create(DDTags.LANGUAGE_TAG_KEY, DDTags.LANGUAGE_TAG_VALUE);

@Override
public AgentSpan afterStart(final AgentSpan span) {
public void afterStart(final AgentSpan span) {
span.setTag(SPAN_KIND_ENTRY);
span.setTag(LANG_ENTRY);

return super.afterStart(span);
super.afterStart(span);
}
}
Loading