-
Notifications
You must be signed in to change notification settings - Fork 0
/
instrumentation.ts
36 lines (34 loc) · 1.17 KB
/
instrumentation.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import { registerOTel } from "@vercel/otel";
import { diag, DiagConsoleLogger, DiagLogLevel } from "@opentelemetry/api";
import {
isOpenInferenceSpan,
OpenInferenceSimpleSpanProcessor,
} from "@arizeai/openinference-vercel";
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
diag.setLogger(new DiagConsoleLogger(), DiagLogLevel.DEBUG);
export function register() {
registerOTel({
serviceName: "phoenix-next-app",
attributes: {
[SEMRESATTRS_PROJECT_NAME]: "phoenix-next-app",
},
spanProcessors: [
new OpenInferenceSimpleSpanProcessor({
exporter: new OTLPTraceExporter({
headers: {
api_key: process.env["PHOENIX_API_KEY"],
},
url:
process.env["PHOENIX_COLLECTOR_ENDPOINT"] ||
"https://app.phoenix.arize.com/v1/traces",
}),
spanFilter: (span) => {
// Only export spans that are OpenInference spans to negate
return isOpenInferenceSpan(span);
},
}),
],
});
}