Skip to content

Commit

Permalink
Strip quotes from OTEL_EXPORTER_OTLP_HEADERS values
Browse files Browse the repository at this point in the history
Workaround a bug in docker-compose
  • Loading branch information
bloodearnest committed Mar 20, 2024
1 parent db91f4b commit 75523b9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 5 additions & 0 deletions services/tracing.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ def setup_default_tracing(set_global=True):

"""Inspect environment variables and set up exporters accordingly."""
if "OTEL_EXPORTER_OTLP_HEADERS" in os.environ:
# workaround for env file parsing issues
cleaned_headers = os.environ["OTEL_EXPORTER_OTLP_HEADERS"].strip("\"'")
# put back into env to be parsed properlh
os.environ["OTEL_EXPORTER_OTLP_HEADERS"] = cleaned_headers

if "OTEL_EXPORTER_OTLP_ENDPOINT" not in os.environ:
os.environ["OTEL_EXPORTER_OTLP_ENDPOINT"] = "https://api.honeycomb.io"

Expand Down
3 changes: 2 additions & 1 deletion tests/test_tracing.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ def test_setup_default_tracing_console(monkeypatch):


def test_setup_default_tracing_otlp_defaults(monkeypatch):
env = {"PYTHONPATH": "", "OTEL_EXPORTER_OTLP_HEADERS": "foo=bar"}
# add single quotes to test quote stripping
env = {"PYTHONPATH": "", "OTEL_EXPORTER_OTLP_HEADERS": "'foo=bar'"}
monkeypatch.setattr(os, "environ", env)
monkeypatch.setattr(
opentelemetry.exporter.otlp.proto.http.trace_exporter, "environ", env
Expand Down

0 comments on commit 75523b9

Please sign in to comment.