LEAF version: 3.12.x
LEAF component(s): Data service
Issue/Question: I am trying to add distributed tracing to a LEAF-generated data service and have 2 questions.
- The LEAF docs mention support for OpenTracing implementations. OpenTracing was deprecated in 2022 and replaced with OpenTelemetry. Does LEAF have support for OpenTelemetry (with or without installed bridges) - and if not are there any first-class alternatives?
- The LEAF JavaDocs have a TracerUtils class - I am not able to import it even after adding the referenced gradle dependencies in the docs. Is there another dependency to add?
Thank you in advance for any assistance.
LEAF does still use the OpenTracing Tracer interfaces, but the implementation LEAF provides by default is the OpenTelemetry one.
In the project I work on now, I have:
implementation "com.leidos.leaf:platform-services-open-tracing"
in my build.gradle. And the version is managed by the LEAF Gradle plugin. Specifically I’m using 3.16.0 per this:
apply plugin: "com.leidos.leaf.base"
leaf {
frameworkVersion = "3.16.3"
platformVersion = "3.16.0"
}
That should transitively bring in the framework-services-core package, I would think, but if not make sure you also have it, or something that brings it in (most every framework-services-x` package brings it in transitively).
If you can paste in your build.gradle that might help with diagnosing why the packages aren’t available.
Hi @mark.a.alvaro,
Thanks for your quick response. That is good to know about the tracing implementation. Re: TracerUtils class. Here are the LEAF plugins/dependencies in my build.gradle. I can access all other tracing related code (e.g TracerHook, DataChangeEventTracerHook) - just not the utils class.
plugins {
id "com.leidos.leaf.base" version "3.12.0" apply false
}
...
subprojects {
apply plugin: "com.leidos.leaf.base"
leaf {
frameworkVersion = "3.12.1"
platformVersion = "3.12.1"
}
dependencies {
api "com.leidos.leaf:framework-services-rest-easy"
api "com.leidos.leaf:framework-services-rest"
api "com.leidos.leaf:framework-services-metrics"
api "com.leidos.leaf:framework-services-prometheus"
api "com.leidos.leaf:framework-services-jetty"
api "com.leidos.leaf:framework-services-mongo"
api "com.leidos.leaf:framework-services-kafka"
api "com.leidos.leaf:platform-services-core"
api "com.leidos.leaf:platform-services-message-handling"
implementation "com.leidos.leaf:platform-services-open-tracing"
implementation "com.leidos.leaf:platform-services-service-discovery"
}
}
Ah sorry should have paid a bit more attention to the file name. TracerUtils is a test util in LEAF that’s not published/meant for production use. The classes you want to use are below:
// Make tracer and register globally.
OpenTracingHandler openTracingHandler = OpenTracingHandler.newBuilder()
.withServiceName("MyApplication")
.build();
GlobalTracer.registerIfAbsent(openTracingHandler::getTracer);
// Make TracerHook and apply to IDataService
// Note you can apply to other hookable LEAF services too
// (e.g. IEventService, IFileService)!
TracerHook tracerHook = TracerHook.newBuilder()
.withShouldHook(method -> !method.getIdentifier()
.equals(MetadataServiceExtensible.LOAD_BEAN_METADATA_BY_EDITIONS))
.build();
this.dataService.addOutermostHook(IDataService.SERVICE_PRED, tracerHook);
2 Likes