OpenTracing#setTag vs ElasticAPM#setLabel

When using the ElasticAPM Openbridge, does this mean that functionality such as ElasticAPM.setLabel needs to be replaced with calls to the OpenTracing API?

Does this also means that it is not possible to use setType when using the OpenTracingBridge?

Cheers,
Milan

You can use both the agent API and the OpenTracing API at the same time if you want to. You can also set the type via the OT API by using the co.elastic.apm.opentracing.ElasticApmTags#TYPE constant.

Oke, Ill continue testing this then as I currently have a scenario where the label is not being set when using the ElasticAPMAgent but is working with the OpentracingAgent.

Hello @milanvdm,

Based on @felixbarny, I wrote a simple demo to define "co.elastic.apm.api.Transaction#type" through OpenTracing APIs.

Demo: https://github.com/cyrille-leclerc/my-elasticapm-custom-instrumentation/tree/set-transaction-type

Code snippet

import co.elastic.apm.api.Transaction;
import co.elastic.apm.opentracing.ElasticApmTags;
...
Span span = tracer.buildSpan("MessageSender#send").start();
try (Scope scope = tracer.scopeManager().activate(span)) {
   ...
   Tags.SPAN_KIND.set(tracer.activeSpan(), Tags.SPAN_KIND_CLIENT);
   Tags.MESSAGE_BUS_DESTINATION.set(tracer.activeSpan(), queueUrl);
   // the transaction type you want: the standard 'request' or a custom type
   ElasticApmTags.TYPE.set(tracer.activeSpan(), Transaction.TYPE_REQUEST);
   ...
} catch (Exception e) {
   Tags.ERROR.set(span, true);
   throw e;
} finally {
   span.finish();
}

Sample Elastic APM Transaction JSON document with transaction.type defined using OpenTracing APIs: https://github.com/cyrille-leclerc/my-elasticapm-custom-instrumentation/blob/set-transaction-type/docs/elastic-apm-open-tracing-with-tx-type-amazon-sqs-distributed-trace.json

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.