electric icon indicating copy to clipboard operation
electric copied to clipboard

Add a `OTEL_DEBUG` env variable for enabling debug mode

Open KyleAMathews opened this issue 1 year ago • 3 comments

Right now we use an OTEL_EXPORT variable for switching between debug mode & exporting to an opentelemetry service — https://github.com/electric-sql/electric/blob/5cd4a9595f86199ebc6ea1039152025de75859cb/packages/sync-service/config/runtime.exs#L35-L70

Instead we should add an OTEL_DEBUG which enable debug mode and otherwise export if the other otel configuration is correct.

KyleAMathews avatar Sep 16 '24 17:09 KyleAMathews

@kevin-dp, my interpretation is that OTEL_EXPORT from OTEL_DEBUG. Where you can have the two behaviours commutatively like:

  • OTEL_DEBUG=1 prints data to stdout
  • OTEL_EXPORT=otlp exports data

I think in this case we don't care about the specific value of OTEL_EXPORT, just that it is set

balegas avatar Sep 30 '24 11:09 balegas

@balegas Why OTEL_DEBUG=1 and not OTEL_DEBUG=true? We've been using boolean values for configuration flags so far.

Even though it's not spelled out in the issue description, I remember @KyleAMathews saying that OTEL_EXPORT is unnecessary, setting OTLP_ENDPOINT by itself should be enough to enable the export, while OTEL_DEBUG is a complementary option that can enable debug logging to stdout independently from the OTLP export config.

alco avatar Sep 30 '24 13:09 alco

yeah, it's not an either or — OTEL_DEBUG overrides OTEL_EXPORT when set — it's like any other DEBUG=true mode.

Actually now that I think about it — we'd still want to send traces to an external services even when we're debugging locally. So OTEL_DEBUG just adds output to the terminal.

Agree that OTEL_DEBUG=true makes more sense. That's how most env variable settings work afaik.

KyleAMathews avatar Sep 30 '24 15:09 KyleAMathews