Is there a way to add environment ("development" o...
# agents
f
Is there a way to add environment ("development" or "production") to the tracer instead of leaving it "default"?
Copy code
try:
        langfuse_auth = base64.b64encode(f"{public_key}:{secret_key}".encode()).decode()

        os.environ["OTEL_EXPORTER_OTLP_ENDPOINT"] = (
            f"{host.rstrip('/')}/api/public/otel"
        )
        os.environ["OTEL_EXPORTER_OTLP_HEADERS"] = (
            f"Authorization=Basic {langfuse_auth}"
        )

        trace_provider = TracerProvider()
        trace_provider.add_span_processor(BatchSpanProcessor(OTLPSpanExporter()))

        set_tracer_provider(trace_provider, metadata=metadata)

        return trace_provider

    except Exception as e:
        raise
r
Have you tried something like this?
Copy code
metadata = {"environment": "production"}  # or "development"  
set_tracer_provider(trace_provider, metadata=metadata)
f
Still appears in the "default" environment in my Langfuse session dashboard.
c
Copy code
"langfuse.environment": stage,
Does the trick, if you use are using LangFuse
f
Thank you!
os.environ["OTEL_RESOURCE_ATTRIBUTES"] = (
f"langfuse.environment={get_env_var('ENVIRONMENT').lower()}"
)
This did it for me.
👍 1
c
I see, that should work, you also just pass it in using the same way the session id is set in the livekit docs for this feature