UNPKG

@traceloop/instrumentation-vertexai

Version:
61 lines (56 loc) 2.15 kB
import { InstrumentationConfig, InstrumentationBase, InstrumentationModuleDefinition } from '@opentelemetry/instrumentation'; import * as aiplatform from '@google-cloud/aiplatform'; import * as vertexAI from '@google-cloud/vertexai'; interface VertexAIInstrumentationConfig extends InstrumentationConfig { /** * Whether to log prompts, completions and embeddings on traces. * @default true */ traceContent?: boolean; /** * A custom logger to log any exceptions that happen during span creation. */ exceptionLogger?: (e: Error) => void; } interface AIPlatformInstrumentationConfig extends InstrumentationConfig { /** * Whether to log prompts, completions and embeddings on traces. * @default true */ traceContent?: boolean; /** * A custom logger to log any exceptions that happen during span creation. */ exceptionLogger?: (e: Error) => void; } declare class AIPlatformInstrumentation extends InstrumentationBase { protected _config: AIPlatformInstrumentationConfig; constructor(config?: AIPlatformInstrumentationConfig); setConfig(config?: AIPlatformInstrumentationConfig): void; protected init(): InstrumentationModuleDefinition; manuallyInstrument(module: typeof aiplatform): void; private wrap; private unwrap; private wrapperMethod; private _startSpan; private _wrapPromise; private _endSpan; private _shouldSendPrompts; } declare class VertexAIInstrumentation extends InstrumentationBase { protected _config: VertexAIInstrumentationConfig; constructor(config?: VertexAIInstrumentationConfig); setConfig(config?: VertexAIInstrumentationConfig): void; protected init(): InstrumentationModuleDefinition; manuallyInstrument(module: typeof vertexAI): void; private wrap; private unwrap; private wrapperMethod; private _startSpan; private _wrapPromise; private _endSpan; private _formatPartsData; private _shouldSendPrompts; } export { AIPlatformInstrumentation, VertexAIInstrumentation }; export type { AIPlatformInstrumentationConfig, VertexAIInstrumentationConfig };