diff --git a/packages/instrumentation-openai/src/instrumentation.ts b/packages/instrumentation-openai/src/instrumentation.ts index 2d0b5bc3..4a0bd03a 100644 --- a/packages/instrumentation-openai/src/instrumentation.ts +++ b/packages/instrumentation-openai/src/instrumentation.ts @@ -66,8 +66,9 @@ import { // Use `DEBUG=elastic-opentelemetry-instrumentation-openai ...` for debug output. // Or use `node --env-file ./dev.env ...` in this repo. -import createDebug from 'debug'; -const debug = createDebug('elastic-opentelemetry-instrumentation-openai'); +import Debug from 'debug'; +const debug = Debug('elastic-opentelemetry-instrumentation-openai'); +// eslint-disable-next-line @typescript-eslint/no-explicit-any (debug as any).inspectOpts = { depth: 50, colors: true }; export class OpenAIInstrumentation extends InstrumentationBase { @@ -157,16 +158,19 @@ export class OpenAIInstrumentation extends InstrumentationBase any) => { // https://platform.openai.com/docs/api-reference/chat/create + // eslint-disable-next-line @typescript-eslint/no-explicit-any return function patchedCreate(this: any, ...args: unknown[]) { if (!self.isEnabled) { return original.apply(this, args); } debug('OpenAI.Chat.Completions.create args: %O', args); - const params = - args[0] as any; /* type ChatCompletionCreateParamsStreaming */ + /** type ChatCompletionCreateParamsStreaming */ + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const params = args[0] as any; const config = self.getConfig(); const startNow = performance.now(); @@ -183,6 +187,7 @@ export class OpenAIInstrumentation extends InstrumentationBase = context.with(ctx, () => original.apply(this, args) ); @@ -239,7 +244,7 @@ export class OpenAIInstrumentation extends InstrumentationBase { // `msg` is Array let body; @@ -328,6 +334,7 @@ export class OpenAIInstrumentation extends InstrumentationBase { return { id: tc.id, @@ -388,6 +395,7 @@ export class OpenAIInstrumentation extends InstrumentationBase, span: Span, startNow: number, @@ -401,6 +409,7 @@ export class OpenAIInstrumentation extends InstrumentationBase c.finish_reason) ); span.setAttribute(ATTR_GEN_AI_RESPONSE_ID, result.id); @@ -542,6 +553,7 @@ export class OpenAIInstrumentation extends InstrumentationBase { let message: Partial; if (config.captureMessageContent) { @@ -553,6 +565,7 @@ export class OpenAIInstrumentation extends InstrumentationBase { return { id: tc.id, @@ -640,8 +653,10 @@ export class OpenAIInstrumentation extends InstrumentationBase { // https://platform.openai.com/docs/api-reference/embeddings/create + // eslint-disable-next-line @typescript-eslint/no-explicit-any return function patchedCreate(this: any, ...args: unknown[]) { if (!self.isEnabled) { return original.apply(this, args); @@ -664,6 +679,7 @@ export class OpenAIInstrumentation extends InstrumentationBase original.apply(this, args)); apiPromise + // eslint-disable-next-line @typescript-eslint/no-explicit-any .then((result: any) => { self._onEmbeddingsCreateResult(span, startNow, commonAttrs, result); }) @@ -682,6 +698,7 @@ export class OpenAIInstrumentation extends InstrumentationBase