TracingBackend
A tracing backend: what one integration contributes to Tracing.create.
Tracing.create builds the two backends that need nothing beyond core - NoOp and Console - itself, and hands every other TracingMode to the backend registered for it. Adding a backend is then adding a dependency, with no edit to core: the same arrangement slice 4 gave providers (#1131, #1133).
Implementations must be a plain class with a public no-arg constructor, '''not''' a Scala object: java.util.ServiceLoader instantiates the named class, and an object exposes its instance as a MODULE$ field instead.
class DatadogTracingBackend extends TracingBackend:
val mode: TracingMode = TracingMode.Named("datadog")
def create(settings: TracingSettings): Result[Tracing] =
settings.extras.get("apiKey").toRight(ConfigurationError("llm4s.tracing.datadog.apiKey is not set"))
.map(new DatadogTracing(_))
A backend's settings live under llm4s.tracing.<mode> and reach it as settings.extras: that block for the selected mode, flattened to strings. Ship their defaults and ${?VAR} bindings in the backend module's own reference.conf.
Declare the class in META-INF/services/org.llm4s.trace.spi.TracingBackend and TRACING_MODE=datadog selects it. A backend can also be registered explicitly through TracingBackends.of or TracingBackends.withBackend and passed to Tracing.fromSettings, which is the answer for a shaded fat jar whose services files did not survive.
Attributes
- Graph
-
- Supertypes
-
class Objecttrait Matchableclass Any
- Known subtypes
-
class LangfuseTracingBackend