-
-
Notifications
You must be signed in to change notification settings - Fork 172
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
OpenTelemetry Protocol (OTLP) appender #374
Conversation
Changes: - No longer throw on invalid compile-time :min-level - Add `:_init-config` map to `*config*` to help users understand/debug load-time config
Libraries printing information without control are often a nuisance.
62a90ad
to
f47e9a8
Compare
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.
f47e9a8
to
d9fa6db
Compare
assoc-some-nx is like `taoensso.encore/assoc-nx` but using `taoensso.encore/assoc-some` instead of `clojure.core/assoc`.
c49fdd1
to
2224d25
Compare
b6a6429
to
9f2d58f
Compare
c1806d6
to
f845fc6
Compare
aaa32f5
to
55265ba
Compare
@devurandom Hi Dennis, thanks for this! Will take a proper look next time I'm doing batched work on Timbre 👍 No need to worry about rebasing, I'll take care of that during review. |
51a3b72
to
01513d4
Compare
@ptaoussanis Hi Peter! Is there anything I can do to help get this merged? |
…evurandom) Once <steffan-westcott/clj-otel#8> is implemented, the actual log emission should be replaced with clj-otel's API.
@devurandom Hi Dennis, apologies for the delay! I would have included this in yesterday's update (v6.4.0), but that was a bit of a rush and mostly intended as a hotfix release. I've manually merged your PR here, thanks for all the work on this! 🙏 I made a few superficial changes, just to try keep a ~consistent style between the various appenders. Please let me know if you're happy with that commit, in which case I'll aim to cut a new release in the next few days. Cheers! :-) |
Hi Peter! Thanks! I looked at Re: By now v2.0 of the Java SDK has been released, so we could just link to its changelog (instead of linking to a GH issue and the changelog with the early notification): https://github.com/open-telemetry/opentelemetry-java-instrumentation/blob/v2.0.0/CHANGELOG.md#version-200-2024-01-12 Is there a particular reason you use URL shorteners for links in comments? I imagine they would be inconvenient if they ever become unavailable. It would be hard to figure out what they linked to and also archives would probably only have indexed the original link, but not the shortened one. |
…evurandom) Once <steffan-westcott/clj-otel#8> is implemented, the actual log emission should be replaced with clj-otel's API.
24cb3e9
to
b72cc65
Compare
Requires com.github.steffan-westcott/clj-otel-api.
With Java Agent
Activate an appender configured by the OpenTelemetry Java Agent:
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.
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:
If you already have an instance of
GlobalOpenTelemetry
, e.g. createdby the OpenTelemetry Java Agent, you need to prevent setting the newly
created SDK as the global default:
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.