in apm-agent-plugins/apm-api-plugin/src/main/java/co/elastic/apm/agent/pluginapi/TracedInstrumentation.java [78:137]
public static Object onMethodEnter(
@Advice.Origin Class<?> clazz,
@SimpleMethodSignatureOffsetMappingFactory.SimpleMethodSignature String signature,
@AnnotationValueOffsetMappingFactory.AnnotationValueExtractor(annotationClassName = "co.elastic.apm.api.Traced", method = "value") String spanName,
@AnnotationValueOffsetMappingFactory.AnnotationValueExtractor(annotationClassName = "co.elastic.apm.api.Traced", method = "type") String type,
@AnnotationValueOffsetMappingFactory.AnnotationValueExtractor(annotationClassName = "co.elastic.apm.api.Traced", method = "subtype") @Nullable String subtype,
@AnnotationValueOffsetMappingFactory.AnnotationValueExtractor(annotationClassName = "co.elastic.apm.api.Traced", method = "action") @Nullable String action,
@AnnotationValueOffsetMappingFactory.AnnotationValueExtractor(
annotationClassName = "co.elastic.apm.api.Traced",
method = "asExit",
defaultValueProvider = AnnotationValueOffsetMappingFactory.FalseDefaultValueProvider.class
) boolean asExit,
@AnnotationValueOffsetMappingFactory.AnnotationValueExtractor(
annotationClassName = "co.elastic.apm.api.Traced",
method = "discardable",
defaultValueProvider = AnnotationValueOffsetMappingFactory.TrueDefaultValueProvider.class
) boolean discardable) {
final TraceState<?> activeContext = tracer.currentContext();
final AbstractSpan<?> parentSpan = activeContext.getSpan();
if (parentSpan != null) {
if (activeContext.shouldSkipChildSpanCreation()) {
// span limit reached means span will not be reported, thus we can optimize and skip creating one
logger.debug("Not creating span for {} because span limit is reached.", signature);
return null;
}
Span<?> span = asExit ? activeContext.createExitSpan() : activeContext.createSpan();
if (span == null) {
return null;
}
span.withType(type.isEmpty() ? "app" : type)
.withSubtype(subtype)
.withAction(action)
.withName(spanName.isEmpty() ? signature : spanName);
if (!discardable) {
span.setNonDiscardable();
}
return span.activate();
}
Transaction<?> transaction = tracer.startRootTransaction(PrivilegedActionUtils.getClassLoader(clazz));
if (transaction == null) {
return null;
}
transaction.setFrameworkName(FRAMEWORK_NAME);
String name;
int namePriority;
if (spanName.isEmpty()) {
name = signature;
namePriority = PRIORITY_METHOD_SIGNATURE;
} else {
name = spanName;
namePriority = PRIORITY_USER_SUPPLIED;
}
return transaction.withName(name, namePriority)
.withType(type.isEmpty() ? Transaction.TYPE_REQUEST : type)
.activate();
}