Conversation
|
Hints for reviewers: EDIT: rebased on master and force-pushed |
bye bye tracer null checks
| private static final Logger logger = LoggerFactory.getLogger(GlobalTracer.class); | ||
|
|
||
| private static final GlobalTracer INSTANCE = new GlobalTracer(); | ||
| private volatile Tracer tracer = NoopTracer.INSTANCE; |
There was a problem hiding this comment.
Currently, we don't declare the tracer volatile as it's usually created once on startup and never changed in non-test scenarios.
SylvainJuge
left a comment
There was a problem hiding this comment.
LGTM, only few minor questions & comments.
apm-agent-core/src/main/java/co/elastic/apm/agent/impl/GlobalTracer.java
Outdated
Show resolved
Hide resolved
apm-agent-core/src/main/java/co/elastic/apm/agent/bci/ElasticApmAgent.java
Outdated
Show resolved
Hide resolved
apm-agent-core/src/main/java/co/elastic/apm/agent/bci/ElasticApmAgent.java
Outdated
Show resolved
Hide resolved
apm-agent-core/src/main/java/co/elastic/apm/agent/bci/ElasticApmAgent.java
Outdated
Show resolved
Hide resolved
apm-agent-core/src/main/java/co/elastic/apm/agent/bci/TracerAwareElasticApmInstrumentation.java
Outdated
Show resolved
Hide resolved
apm-agent-core/src/main/java/co/elastic/apm/agent/impl/GlobalTracer.java
Outdated
Show resolved
Hide resolved
|
|
||
| public AsyncHandlerOnCompletedInstrumentation() { | ||
| super(named("onCompleted").and(takesArguments(0))); | ||
| public AsyncHandlerOnCompletedInstrumentation(ElasticApmTracer tracer) { |
There was a problem hiding this comment.
Why do we have to provide tracer explicitly here ? shouldn't we use make AsyncHandlerOnCompletedInstrumentation extend TracerAwareElasticApmInstrumentation ?
There was a problem hiding this comment.
It's because co.elastic.apm.agent.bci.HelperClassManager.ForAnyClassLoader requires a ElasticApmTracer
| String operationName, long microseconds, | ||
| @Nullable Iterable<Map.Entry<String, String>> baggage, ClassLoader applicationClassLoader) { | ||
| AbstractSpan<?> result = null; | ||
| ElasticApmTracer tracer = GlobalTracer.getTracerImpl(); |
There was a problem hiding this comment.
Why can't we use GlobalTracer.get() here instead ?
There was a problem hiding this comment.
Because Tracer#startSpan is not part of the Tracer interface. That is because it returns a non-null span but because the NoopTracer only returns nulls, we can't add it to the interface. Normally it's not an issue because spans are started via getActive().createSpan
| @VisibleForAdvice | ||
| @Nullable | ||
| public static TraceContext parseTextMap(Iterable<Map.Entry<String, String>> textMap) { | ||
| ElasticApmTracer tracer = GlobalTracer.getTracerImpl(); |
There was a problem hiding this comment.
as previous, why not use GlobalTracer.get() ?
There was a problem hiding this comment.
Similar reason: because TraceContext needs a ElasticApmTracer instance so it can start spans.
|
Merged on the command line via dd3e45f |
What does this PR do?
Depends on #1230
Removes the need for tedious
if (tracer != null)checks.The separation of
ElasticApmInstrumentationfromTracerAwareElasticApmInstrumentationis a preparation step for creating aapm-agent-plugin-sdkmodule needed for #937.Checklist
I have updated CHANGELOG.asciidoc