MCPcopy Index your code
hub / github.com/FlowiseAI/Flowise / getPhoenixTracer

Function getPhoenixTracer

packages/components/src/handler.ts:95–138  ·  view source on GitHub ↗
(options: PhoenixTracerOptions)

Source from the content-addressed store, hash-verified

93}
94
95export function getPhoenixTracer(options: PhoenixTracerOptions): Tracer | undefined {
96 const SEMRESATTRS_PROJECT_NAME = 'openinference.project.name'
97 try {
98 const parsedURL = new URL(options.baseUrl)
99 const baseEndpoint = `${parsedURL.protocol}//${parsedURL.host}`
100
101 // Remove trailing slashes
102 let path = parsedURL.pathname.replace(/\/$/, '')
103
104 // Remove any existing /v1/traces suffix
105 path = path.replace(/\/v1\/traces$/, '')
106
107 const exporterUrl = `${baseEndpoint}${path}/v1/traces`
108 const exporterHeaders = {
109 api_key: options.apiKey || '',
110 authorization: `Bearer ${options.apiKey || ''}`
111 }
112
113 const traceExporter = new ProtoOTLPTraceExporter({
114 url: exporterUrl,
115 headers: exporterHeaders
116 })
117 const tracerProvider = new NodeTracerProvider({
118 resource: new Resource({
119 [ATTR_SERVICE_NAME]: options.projectName,
120 [ATTR_SERVICE_VERSION]: '1.0.0',
121 [SEMRESATTRS_PROJECT_NAME]: options.projectName
122 })
123 })
124 tracerProvider.addSpanProcessor(new SimpleSpanProcessor(traceExporter))
125 if (options.enableCallback) {
126 registerInstrumentations({
127 instrumentations: []
128 })
129 const lcInstrumentation = new LangChainInstrumentation()
130 lcInstrumentation.manuallyInstrument(CallbackManagerModule)
131 tracerProvider.register()
132 }
133 return tracerProvider.getTracer(`phoenix-tracer-${uuidv4().toString()}`)
134 } catch (err) {
135 if (process.env.DEBUG === 'true') console.error(`Error setting up Phoenix tracer: ${err.message}`)
136 return undefined
137 }
138}
139
140interface OpikTracerOptions {
141 apiKey: string

Callers 3

handler.test.tsFile · 0.90
additionalCallbacksFunction · 0.85
initializeProviderMethod · 0.85

Calls 1

registerMethod · 0.65

Tested by

no test coverage detected