/** * IntrospectionLogs — OTel logs exporter for Introspection. * * Owns its own `LoggerProvider` and OTLP log exporter. Provides `track`, * `feedback`, `identify`, and async-context helpers (`withBaggage`, * `withAgent`, `withConversation`, etc.) that propagate identity and * gen_ai context through OpenTelemetry baggage. * * Fully independent of {@link IntrospectionClient}. Construct it directly * with the OTel peer dependencies installed. * * @example * ```typescript * import { IntrospectionLogs } from "@introspection-sdk/introspection-node/otel"; * * const logs = new IntrospectionLogs({ * token: process.env.INTROSPECTION_TOKEN, * serviceName: "my-service", * }); * * await logs.withAgent("support-bot", "agent_1", () => * logs.withConversation("conv_123", undefined, () => { * logs.feedback("thumbs_up", { comments: "Great answer" }); * }), * ); * * await logs.shutdown(); * ``` */ import { type LogRecordExporter } from "@opentelemetry/sdk-logs"; import { type FeedbackOptions, type UserTraits } from "../types.js"; /** * Configuration for {@link IntrospectionLogs}. */ export interface IntrospectionLogsOptions { /** Authentication token (env: INTROSPECTION_TOKEN). */ token?: string; /** Service name for telemetry (env: INTROSPECTION_SERVICE_NAME, default: "introspection-client"). */ serviceName?: string; /** * Base URL for the OTLP collector (env: INTROSPECTION_BASE_OTEL_URL, * default: "https://otel.introspection.dev"). */ baseOtelUrl?: string; /** Additional HTTP headers to include in exporter requests. */ additionalHeaders?: Record; /** Flush interval in milliseconds (default: 5000). */ flushInterval?: number; /** Maximum export batch size (default: 100). */ maxBatchSize?: number; /** * Maximum records buffered before new ones are dropped. Omit to keep the * OTel SDK's default. See {@link AdvancedOptions.maxQueueSize}. */ maxQueueSize?: number; /** * How long one export may take before it is abandoned, in milliseconds. * Omit to keep the OTel SDK's default. */ exportTimeoutMillis?: number; /** * Custom log record exporter, bypassing OTLP construction. * * The analytics stream is the contract that has to match across SDKs, and * this is the seam for asserting what goes out on it. Matches the Python * SDK's `log_exporter` constructor argument, the Rust config's * `log_exporter`, and the browser client's `advanced.logExporter`. */ logExporter?: LogRecordExporter; } export declare class IntrospectionLogs { private loggerProvider; private otelLogger; constructor(options?: IntrospectionLogsOptions); /** Get gen_ai context from baggage */ private getGenAiFromContext; /** * Get identity from baggage. * * Baggage only, deliberately. This used to fall back to `userId` / * `anonymousId` held on the instance, but `init()` builds one instance per * process: under any concurrency, the identity of whichever request called * `identify()` last attached itself to every other request's events. Scope * identity with {@link withUserId} / {@link withAnonymousId} instead, which * carry it on the async context where it belongs. */ private getIdentityFromContext; private getTimestamp; private buildAttributes; track(eventName: string, properties?: Record, options?: { eventId?: string; }): void; feedback(name: string, options?: FeedbackOptions): void; /** * Emit an `identify` event associating `userId` with `traits`. * * The identity lands on this event only. It does not persist onto later * `track` / `feedback` calls — wrap those in {@link withUserId} (or set the * baggage yourself) to scope identity across several events. */ identify(userId: string, traits?: UserTraits, anonymousId?: string, eventId?: string): void; createBaggageContext(values: Record): import("@opentelemetry/api").Context; withBaggage(values: Record, callback: () => T | Promise): Promise; withAgent(agentName: string, agentId: string | undefined, callback: () => T | Promise): Promise; withConversation(conversationId: string | undefined, previousResponseId: string | undefined, callback: () => T | Promise): Promise; withUserId(userId: string, callback: () => T | Promise): Promise; withAnonymousId(anonymousId: string, callback: () => T | Promise): Promise; /** The user id on the current async context, if one is scoped. */ getUserId(): string | undefined; /** The anonymous id on the current async context, if one is scoped. */ getAnonymousId(): string | undefined; flush(): Promise; shutdown(): Promise; } //# sourceMappingURL=logs.d.ts.map