(options: ArizeTracerOptions)
| 50 | } |
| 51 | |
| 52 | function getArizeTracer(options: ArizeTracerOptions): Tracer | undefined { |
| 53 | const SEMRESATTRS_PROJECT_NAME = 'openinference.project.name' |
| 54 | try { |
| 55 | const metadata = new Metadata() |
| 56 | metadata.set('api_key', options.apiKey) |
| 57 | metadata.set('space_id', options.spaceId) |
| 58 | const traceExporter = new GrpcOTLPTraceExporter({ |
| 59 | url: `${options.baseUrl}/v1`, |
| 60 | metadata |
| 61 | }) |
| 62 | const tracerProvider = new NodeTracerProvider({ |
| 63 | resource: new Resource({ |
| 64 | [ATTR_SERVICE_NAME]: options.projectName, |
| 65 | [ATTR_SERVICE_VERSION]: '1.0.0', |
| 66 | [SEMRESATTRS_PROJECT_NAME]: options.projectName, |
| 67 | model_id: options.projectName |
| 68 | }) |
| 69 | }) |
| 70 | tracerProvider.addSpanProcessor(new SimpleSpanProcessor(traceExporter)) |
| 71 | if (options.enableCallback) { |
| 72 | registerInstrumentations({ |
| 73 | instrumentations: [] |
| 74 | }) |
| 75 | const lcInstrumentation = new LangChainInstrumentation() |
| 76 | lcInstrumentation.manuallyInstrument(CallbackManagerModule) |
| 77 | tracerProvider.register() |
| 78 | } |
| 79 | return tracerProvider.getTracer(`arize-tracer-${uuidv4().toString()}`) |
| 80 | } catch (err) { |
| 81 | if (process.env.DEBUG === 'true') console.error(`Error setting up Arize tracer: ${err.message}`) |
| 82 | return undefined |
| 83 | } |
| 84 | } |
| 85 | |
| 86 | interface PhoenixTracerOptions { |
| 87 | apiKey: string |
no test coverage detected