Hey all, trying to set the Phoenix Project name while running with llamaindex workflows but setting the environment variable isn't working for me, anything i'm missing?
Setting the Phoenix project name via the environment variable PHOENIX_PROJECT_NAME should work, but it must be done before any instrumentation is initialized. This approach is typically effective in notebook environments. If you're running a server or a more complex application, you might need to set the project name in the resource attributes for the trace provider.Here's an example of how to set the project name in the resource attributes: LBKSfrom openinference.semconv.resource import ResourceAttributes from openinference.instrumentation.llama_index import LlamaIndexInstrumentor from opentelemetry import trace as trace_api from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter from opentelemetry.sdk import trace as trace_sdk from opentelemetry.sdk.resources import Resource from opentelemetry.sdk.trace.export import SimpleSpanProcessorLBKSresource = Resource(attributes={ ResourceAttributes.PROJECT_NAME: '<your-project-name> ' }) tracer_provider = trace_sdk.TracerProvider(resource=resource) span_exporter = OTLPSpanExporter(endpoint="[http://phoenix:6006/v1/traces](http://phoenix:6006/v1/traces)") span_processor = SimpleSpanProcessor(span_exporter=span_exporter) tracer_provider.add_span_processor(span_processor=span_processor) trace_api.set_tracer_provider(tracer_provider=tracer_provider) LlamaIndexInstrumentor().instrument()LBKSWould you like more details on this setup?Sources:
- GitHub Issue #3375
- Customize Traces Documentation
💡 Hint: Mention RunLLM in the thread for followups.
tried this but didn't work
Interesting, can you provide a small MRE? It’s hard to tell what might be going on from your description alone. We also supply the “using_project” context manager in Phoenix which is intended primarily for notebook use, but might temporarily solve your problem while we figure this out
this is the code that I am testing in a notebook at the moment, not sure if that helps `import os os.environ["OTEL_EXPORTER_OTLP_HEADERS"] = "api_key=..." os.environ["PHOENIX_CLIENT_HEADERS"] = "api_key=..." os.environ["PHOENIX_COLLECTOR_ENDPOINT"] = "https://app.phoenix.arize.com" os.environ['PHOENIX_PROJECT_NAME'] = "test_project" from opentelemetry.sdk import trace as trace_sdk from opentelemetry.sdk.trace.export import SimpleSpanProcessor from opentelemetry.exporter.otlp.proto.http.trace_exporter import ( OTLPSpanExporter as HTTPSpanExporter, ) from openinference.instrumentation.llama_index import LlamaIndexInstrumentor # Add Phoenix span_phoenix_processor = SimpleSpanProcessor(HTTPSpanExporter(endpoint="https://app.phoenix.arize.com/v1/traces")) # Add them to the tracer tracer_provider = trace_sdk.TracerProvider() tracer_provider.add_span_processor(span_processor=span_phoenix_processor) # Instrument the application LlamaIndexInstrumentor().instrument(tracer_provider=tracer_provider)`
Ah yeah, the PHOENIX_PROJECT_NAME environment variable is only wired up for our Phoenix openinference wrappers, we'll have something more ergonomic for you to use soon. Until then if you're instrumenting the way you are, please try restarting the notebook and setting the project name in the resource. It'll look something like this:
from openinference.semconv.resource import ResourceAttributes
resource = Resource(attributes={
ResourceAttributes.PROJECT_NAME: '<your-project-name>'
})
tracer_provider = trace_sdk.TracerProvider(resource=resource)I know the suggestion above is something like this, but you can only set the resource (and tracer_provider) once, so it might take a full notebook kernel restart for it to take
Let me know if it works!
