Hi, regarding the environment variables `OTEL_EXPO...
# support
a
Hi, regarding the environment variables
OTEL_EXPORTER_OTLP_ENDPOINT=127.0.0.1:4317 \
OTEL_RESOURCE_ATTRIBUTES=service.name=graphql-service
Can we set these inside of the code somehow instead of in the terminal? For example inside the config object of
OTLPTraceExporter
?
a
Copy code
# Should happen even before app starts
if ENABLE_OPENTELEMETRY:
    os.environ["OTEL_EXPORTER_OTLP_TRACES_ENDPOINT"] = f"{OTEL_EXPORTER_OTLP_ENDPOINT}/v1/traces"
    configure_opentelemetry(
        service_name=OTEL_SERVICE_NAME,
        # TODO : Somehow get the paint-task version and populate here to compare canary/staging versions
        service_version="1.0.0",
        span_exporter_endpoint=OTEL_EXPORTER_OTLP_ENDPOINT,
        span_exporter_insecure=True  # Allow everything within AWS
        # Add log_level=debug here
    )
I tried this and seemed to work
however, setting environment variables worked better for me
a
is setting it as an environment variable the only option?
a
Copy code
configure_opentelemetry
you should be able to use this method right>
a
sorry where would I find the function? For context I am running with apollo graphql, I have a separate tracer file set up following this guide
a
Oh IDK, mine is python app though I do use graphql in it too, do I have to do special instrumentation for graphql @Srikanth Chekuri?
s
Can we set these inside of the code somehow instead of in the terminal? For example inside the config object of
OTLPTraceExporter
?
You can do this but you can’t use the auto instrumentation at the same time command if you want do this. Example here https://opentelemetry.io/docs/instrumentation/python/exporters/#otlp-endpoint-or-collector
do I have to do special instrumentation for graphql
There is no instrumentation library for graphql (yet). You would have to write some sort of middleware/wrapper or some manual instrumentation is needed.