(options: OpikTracerOptions)
| 148 | } |
| 149 | |
| 150 | function getOpikTracer(options: OpikTracerOptions): Tracer | undefined { |
| 151 | const SEMRESATTRS_PROJECT_NAME = 'openinference.project.name' |
| 152 | try { |
| 153 | const traceExporter = new ProtoOTLPTraceExporter({ |
| 154 | url: `${options.baseUrl}/v1/private/otel/v1/traces`, |
| 155 | headers: { |
| 156 | Authorization: options.apiKey, |
| 157 | projectName: options.projectName, |
| 158 | 'Comet-Workspace': options.workspace |
| 159 | } |
| 160 | }) |
| 161 | const tracerProvider = new NodeTracerProvider({ |
| 162 | resource: new Resource({ |
| 163 | [ATTR_SERVICE_NAME]: options.projectName, |
| 164 | [ATTR_SERVICE_VERSION]: '1.0.0', |
| 165 | [SEMRESATTRS_PROJECT_NAME]: options.projectName |
| 166 | }) |
| 167 | }) |
| 168 | tracerProvider.addSpanProcessor(new SimpleSpanProcessor(traceExporter)) |
| 169 | if (options.enableCallback) { |
| 170 | registerInstrumentations({ |
| 171 | instrumentations: [] |
| 172 | }) |
| 173 | const lcInstrumentation = new LangChainInstrumentation() |
| 174 | lcInstrumentation.manuallyInstrument(CallbackManagerModule) |
| 175 | tracerProvider.register() |
| 176 | } |
| 177 | return tracerProvider.getTracer(`opik-tracer-${uuidv4().toString()}`) |
| 178 | } catch (err) { |
| 179 | if (process.env.DEBUG === 'true') console.error(`Error setting up Opik tracer: ${err.message}`) |
| 180 | return undefined |
| 181 | } |
| 182 | } |
| 183 | |
| 184 | function tryGetJsonSpaces() { |
| 185 | try { |
no test coverage detected