Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
OpenTelemetry Protocol (OTLP) appender
Requires com.github.steffan-westcott/clj-otel-api. With Java Agent: Activate an appender configured by the OpenTelemetry Java Agent: ```clj (let [logger-provider (.getLogsBridge (GlobalOpenTelemetry/get)) appender (taoensso.timbre.appenders.community.otlp/otlp-appender logger-provider)] (taoensso.timbre/merge-config! {:appenders {:otlp appender}})) ``` Note: When relying on the OpenTelemetry Java Agent 1.x, you need to explicitly enable the logs exporter with `OTEL_LOGS_EXPORTER=otlp`. This will become the default with the release of Java Agent 2.0, cf. * https://github.com/open-telemetry/opentelemetry-java-instrumentation/blob/main/CHANGELOG.md#version-1270-2023-06-14 * open-telemetry/opentelemetry-java-instrumentation#8647 Without Java Agent: If you want autoconfiguration without the Java Agent, you also need io.opentelemetry/opentelemetry-sdk-extension-autoconfigure and io.opentelemetry/opentelemetry-exporter-otlp on the classpath. Create an autoconfigured appender and activate it: ```clj (let [logger-provider (.getSdkLoggerProvider (.getOpenTelemetrySdk (.build (AutoConfiguredOpenTelemetrySdk/builder)))) appender (taoensso.timbre.appenders.community.otlp/otlp-appender logger-provider)] (taoensso.timbre/merge-config! {:appenders {:otlp appender}})) ``` If you already have an instance of `GlobalOpenTelemetry`, e.g. created by the OpenTelemetry Java Agent, you need to prevent setting the newly created SDK as the global default: ```clj (.build (doto (AutoConfiguredOpenTelemetrySdk/builder) (.setResultAsGlobal false))) ``` I took inspiration from `taoensso.timbre.appenders.community.sentry`. Once steffan-westcott/clj-otel#8 is implemented, the actual log emission should be replaced with using clj-otel's API.
- Loading branch information