Troubleshooting OpenTelemetry Initialization with Bun.js Error
Hello everyone, I have a problem while initializing OpenTelemetry instrumentation. I encountered the following error:
L":"E:\\backend-v2\\node_modules\\@opentelemetry\\otlp-exporter-base\\build\\src\\transport\\http-transport-utils.js",
stack":"Error: Request timed out
at <anonymous> (E:\\backend-v2\\node_modules\\@opentelemetry\\otlp-exporter-base\\build\\src\\transport\\http-transport-utils.js:87:24)
at emit (node:events:322:22)
at emitCloseNT (node:http:196:33)
at <anonymous> (node:http:1128:70)
at <anonymous> (native:19:28)
at processTicksAndRejections (native:7:39)",
name":"Error"I am running my application with Bun.js. Additionally, when I run the code, the Phoenix server successfully receives the embeddings. However, requests from OpenAI Assistants encounter issues. How can I fix this? My instrumentations.js file is as follows:
import { SimpleSpanProcessor } from "@opentelemetry/sdk-trace-base";
import { OTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-proto";
import { OpenAIInstrumentation } from "@arizeai/openinference-instrumentation-openai";
import * as OpenAI from "openai";
import { diag, DiagConsoleLogger, DiagLogLevel } from "@opentelemetry/api";
import { registerInstrumentations } from "@opentelemetry/instrumentation";
import { NodeTracerProvider } from "@opentelemetry/sdk-trace-node";
import { Resource } from "@opentelemetry/resources";
// For troubleshooting, set the log level to DiagLogLevel.DEBUG
diag.setLogger(new DiagConsoleLogger(), DiagLogLevel.INFO);
const provider = new NodeTracerProvider({
resource: new Resource({
["openinference.project.name"]: process.env.PHOENIX_PROJECT_NAME,
}),
});
provider.addSpanProcessor(
new SimpleSpanProcessor(
new OTLPTraceExporter({
url: process.env.COLLECTOR_ENDPOINT || "http://localhost:6006/v1/traces",
headers: {
'Authorization': `Bearer ${process.env.PHOENIX_API_KEY}`,
},
timeoutMillis: 500000,
}),
),
);
// OpenAI must be manually instrumented as it doesn't have a traditional module structure
const openAIInstrumentation = new OpenAIInstrumentation({});
openAIInstrumentation.manuallyInstrument(OpenAI);
registerInstrumentations({
instrumentations: [openAIInstrumentation],
});
provider.register();
diag.info("👀 OpenInference initialized");
