Hi all, I've been having a fair amount of trouble getting the demo [next-openi-telemetry-app](https://github.com/Arize-ai/openinference/tree/main/js/examples/next-openai-telemetry-app) demo working. Have attempted every permutation of PHOENIX_COLLECTOR_ENDPOINT and PHOENIX_API_KEY I can think of. Have tried connecting to a live Phoenix Space at https://app.phoenix.arize.com/v1/traces and to local docker instance. Nothing seems to work here. I guess first of all I wanted to verify that this should be working?
Yes, the demo should work with both a live Phoenix Space and a local Docker instance. Here are some key points to verify: 1. Environment Variables: Ensure that PHOENIX_COLLECTOR_ENDPOINT and PHOENIX_API_KEY are correctly set. For a live Phoenix Space, PHOENIX_COLLECTOR_ENDPOINT should be [https://app.phoenix.arize.com/v1/traces](https://app.phoenix.arize.com/v1/traces). For a local Docker instance, it should be [http://localhost:6006/v1/traces](http://localhost:6006/v1/traces).2. Network Accessibility: Ensure that the Phoenix server is accessible from your application. For local Docker, verify that the Docker container is running and accessible on the specified port.3. Instrumentation Initialization: Ensure that the instrumentation code is correctly initialized before any application code is executed. This is crucial for the traces to be captured.Would you like more detailed troubleshooting steps or a code example?Sources:
- https://arize-ai.slack.com/archives/C04R3GXC8HK/p1722778288.923159
- https://arize-ai.slack.com/archives/C04R3GXC8HK/p1720418482.719169
💡 Hint: Mention RunLLM in the thread for followups.
I've been through most steps. This actually helped me spot the issue I was having locally — trying to use the grpc endpoint rather than the http endpoint. The basic issue remains though that attempting to use the exact same, working setup to send traces to a hosted Phoenix just give me a 401 error. API Key has been checked and double checked.
Hey Michael S. - def. can help. Which setup would you like to work on local or the managed phoenix instance?
Seems like I have the local instance settled. That was just for debugging purposes. The big mystery all along has been my inability to connect to the managed instance.
Swapping in PHOENIX_API_KEY and PHOENIX_COLLECTOR_ENDPOINT='https://app.phoenix.arize.com/v1/traces' for the working local vals (no api key for local, obviously) I get the following error logged:
{"stack":"OTLPExporterError: Unauthorized\n at new OTLPExporterError (webpack-internal:///(instrument)/./node_modules/@opentelemetry/otlp-exporter-base/build/esm/types.js:41:28)\n at IncomingMessage.eval (webpack-internal:///(instrument)/./node_modules/@opentelemetry/otlp-exporter-base/build/esm/platform/node/util.js:134:37)\n at IncomingMessage.emit (node:events:529:35)\n at endReadableNT (node:internal/streams/readable:1400:12)\n at process.processTicksAndRejections (node:internal/process/task_queues:82:21)","message":"Unauthorized","name":"OTLPExporterError","code":"401"}I've also attempted to set a space_id header, and tried a few different endpoints I've seen in other examples, but no luck.
So just to set a baseline for repro:
1. Cloned the repo above, went to folder, `npm install`
2. Copied .env.local.example -> .env.local
3. Set env values:
OPENAI_API_KEY='sk-pw-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
PHOENIX_API_KEY='bffXXXXXXXXXXXXXX'
PHOENIX_COLLECTOR_ENDPOINT='http://localhost:6006/v1/traces'
4. Started local Phoenix instance
5. Started npm run dev, verified it logged
6. Changed env value:
PHOENIX_COLLECTOR_ENDPOINT='https://app.phoenix.arize.com/v1/traces'
7. Restarted npm run dev
8. Sent a message. Saw the 401 error logged.
Have attempted with API keys from two different accts, one which has some old traces in it, and one which is new.
Experimenting, I set up auth on the local Phoenix, and noticed that the example is not correct for that — I had to change the headers to authorization: Bearer MY_TOKEN. I've tried something similar against the hosted Phoenix, but no luck.
hey Michael S. sorry got pulled into another meeting. It's actually a bit different in managed phoenix than local phoenix (we are aware that this is confusing - cc Kiko C. Eric X.) So managed phoenix uses keys a bit differently. It has it's own headers:
os.environ["PHOENIX_CLIENT_HEADERS"] = "api_key=...:..."so the key you see in the UI in managed phoenix need to be set as spelled out below 👇
can you give this part a try?
I see — though in this case I'm using openinference and OTEL, not the client, so wouldn't those env params be roughly equivalent?
exporter: new OTLPTraceExporter({
headers: {
api_key: process.env["PHOENIX_API_KEY"]
},
url: process.env["PHOENIX_COLLECTOR_ENDPOINT"] || "https://app.phoenix.arize.com/v1/traces"
}),
