mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-27 13:00:35 +03:00
feat: Enable Tracing Support For Self-Hosted & Cloud Phoenix Instance (#5114)
* feat: Enable Tracing Support For Self-Hosted & Cloud Phoenix Instance * feat: Add Testcase For Phoenix Exporter URL Handling
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { Logger } from 'winston'
|
||||
import { URL } from 'url'
|
||||
import { v4 as uuidv4 } from 'uuid'
|
||||
import { Client } from 'langsmith'
|
||||
import CallbackHandler from 'langfuse-langchain'
|
||||
@@ -91,14 +92,27 @@ interface PhoenixTracerOptions {
|
||||
enableCallback?: boolean
|
||||
}
|
||||
|
||||
function getPhoenixTracer(options: PhoenixTracerOptions): Tracer | undefined {
|
||||
export function getPhoenixTracer(options: PhoenixTracerOptions): Tracer | undefined {
|
||||
const SEMRESATTRS_PROJECT_NAME = 'openinference.project.name'
|
||||
try {
|
||||
const parsedURL = new URL(options.baseUrl)
|
||||
const baseEndpoint = `${parsedURL.protocol}//${parsedURL.host}`
|
||||
|
||||
// Remove trailing slashes
|
||||
let path = parsedURL.pathname.replace(/\/$/, '')
|
||||
|
||||
// Remove any existing /v1/traces suffix
|
||||
path = path.replace(/\/v1\/traces$/, '')
|
||||
|
||||
const exporterUrl = `${baseEndpoint}${path}/v1/traces`
|
||||
const exporterHeaders = {
|
||||
api_key: options.apiKey || '',
|
||||
authorization: `Bearer ${options.apiKey || ''}`
|
||||
}
|
||||
|
||||
const traceExporter = new ProtoOTLPTraceExporter({
|
||||
url: `${options.baseUrl}/v1/traces`,
|
||||
headers: {
|
||||
api_key: options.apiKey
|
||||
}
|
||||
url: exporterUrl,
|
||||
headers: exporterHeaders
|
||||
})
|
||||
const tracerProvider = new NodeTracerProvider({
|
||||
resource: new Resource({
|
||||
|
||||
Reference in New Issue
Block a user