Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 14 additions & 13 deletions js/examples/next-openai-telemetry-app/instrumentation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,32 @@ import {
import { OTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-proto";
import { SEMRESATTRS_PROJECT_NAME } from "@arizeai/openinference-semantic-conventions";

// For troubleshooting, set the log level to DiagLogLevel.DEBUG
// This is not required and should not be added in a production setting
diag.setLogger(new DiagConsoleLogger(), DiagLogLevel.DEBUG);

export function register() {
const spaceId = process.env.ARIZE_SPACE_ID;
const apiKey = process.env.ARIZE_API_KEY;

if (!spaceId || !apiKey) {
throw new Error("ARIZE_SPACE_ID and ARIZE_API_KEY must be set");
}

registerOTel({
serviceName: "phoenix-next-app",
serviceName: "parker-vercel-test",
attributes: {
// This is not required but it will allow you to send traces to a specific
// project in phoenix
[SEMRESATTRS_PROJECT_NAME]: "phoenix-next-app",
model_id: "parker-vercel-model",
model_version: "1.0.0",
},
spanProcessors: [
new OpenInferenceSimpleSpanProcessor({
exporter: new OTLPTraceExporter({
url: "https://otlp.arize.com/v1/traces",
headers: {
api_key: process.env["PHOENIX_API_KEY"],
space_id: spaceId,
api_key: apiKey,
},
url: "http://localhost:6006/v1/traces",
}),
spanFilter: (span) => {
// Only export spans that are OpenInference to remove non-generative spans
// This should be removed if you want to export all spans
return isOpenInferenceSpan(span);
},
spanFilter: (span) => isOpenInferenceSpan(span),
}),
],
});
Expand Down
27 changes: 16 additions & 11 deletions js/examples/next-openai-telemetry-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,27 @@
"lint": "next lint"
},
"dependencies": {
"@ai-sdk/openai": "latest",
"@ai-sdk/react": "latest",
"@arizeai/openinference-semantic-conventions": "^0.10.0",
"@arizeai/openinference-vercel": "^1.0.0",
"@arizeai/openinference-vercel": "^2.0.3",
"@opentelemetry/api": "^1.9.0",
"@opentelemetry/api-logs": "0.52.1",
"@opentelemetry/exporter-trace-otlp-proto": "^0.52.1",
"@opentelemetry/instrumentation": "0.52.1",
"@opentelemetry/sdk-logs": "0.52.1",
"@opentelemetry/exporter-trace-otlp-proto": "^0.57.2",
"@opentelemetry/sdk-trace-base": "^1.25.1",
"@vercel/otel": "1.9.1",
"ai": "latest",
"next": "latest",
"openai": "4.52.6",
"react": "^18",
"react-dom": "^18"
"react-dom": "^18",
"@opentelemetry/api-logs": "^0.57.2",
"@opentelemetry/instrumentation": "^0.57.2",
"@opentelemetry/instrumentation-fetch": "^0.57.2",
"@opentelemetry/resources": "^1.30.0",
"@opentelemetry/sdk-logs": "^0.57.2",
"@opentelemetry/semantic-conventions": "^1.33.0",
"@vercel/blob": "^1.0.1",
"@vercel/otel": "^1.12.0",
"ai": "^4.3.9",
"next": "15.2.0",
"@ai-sdk/google-vertex": "^2.2.21",
"@ai-sdk/openai": "^1.3.21",
"@ai-sdk/react": "^1.2.9"
},
"devDependencies": {
"@types/node": "^18.19.46",
Expand Down
Loading