electric-sql / electric

Sync little subsets of your Postgres data into local apps and services.
https://electric-sql.com
Apache License 2.0
6.46k stars 156 forks source link

Add a `OTEL_DEBUG` env variable for enabling debug mode #1714

Closed KyleAMathews closed 1 month ago

KyleAMathews commented 2 months ago

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.

balegas commented 1 month ago

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

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

alco commented 1 month ago

@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.

KyleAMathews commented 1 month ago

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.