Skip to content

Commit 36655d2

Browse files
committed
feat: Enable Tracing Support For Self-Hosted & Cloud Phoenix Instance
1 parent af1464f commit 36655d2

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

packages/components/src/handler.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { Logger } from 'winston'
2+
import { URL } from 'url'
23
import { v4 as uuidv4 } from 'uuid'
34
import { Client } from 'langsmith'
45
import CallbackHandler from 'langfuse-langchain'
@@ -94,10 +95,14 @@ interface PhoenixTracerOptions {
9495
function getPhoenixTracer(options: PhoenixTracerOptions): Tracer | undefined {
9596
const SEMRESATTRS_PROJECT_NAME = 'openinference.project.name'
9697
try {
98+
const parsed = new URL(options.baseUrl)
99+
const baseEndpoint = `${parsed.protocol}//${parsed.host}`
100+
const path = parsed.pathname.replace(/\/$/, '')
97101
const traceExporter = new ProtoOTLPTraceExporter({
98-
url: `${options.baseUrl}/v1/traces`,
102+
url: `${baseEndpoint}${path}/v1/traces`,
99103
headers: {
100-
api_key: options.apiKey
104+
api_key: options.apiKey || '',
105+
authorization: `Bearer ${options.apiKey || ''}`
101106
}
102107
})
103108
const tracerProvider = new NodeTracerProvider({

0 commit comments

Comments
 (0)