import type { Attributes, Context } from "@opentelemetry/api"; import type { Metadata, PromptTemplate, Session, Tags, User } from "./types"; export declare const ContextAttributes: { readonly "llm.prompt_template.template": symbol; readonly "llm.prompt_template.variables": symbol; readonly "llm.prompt_template.version": symbol; readonly "session.id": symbol; readonly metadata: symbol; readonly "user.id": symbol; readonly "tag.tags": symbol; readonly attributes: symbol; }; /** * Sets the prompt template in the given OpenTelemetry context. * If OI tracer is used in spans created during this active context, the prompt template will be added to the span as an attribute. * @param context - The context to set the prompt template on. * @param promptTemplate - The prompt template to set on the context. * @returns The context * @example * ```typescript * context.with( * setPromptTemplate(context.active(), { * template: "hello {name}", * variables: { name: "world" }, * version: "V1.0" * }), * () => { * // Spans created here will have prompt template attributes * } * ); * ``` */ export declare function setPromptTemplate(context: Context, promptTemplate: PromptTemplate): Context; /** * Clears the prompt template from the given OpenTelemetry context. * @param context - The context to clear the prompt template from. * @returns The context */ export declare function clearPromptTemplate(context: Context): Context; /** * Gets the prompt template from the given OpenTelemetry context. * @param context - The context to get the prompt template from. * @returns The prompt template * @example const promptTemplate = getPromptTemplate(context.active()); */ export declare function getPromptTemplate(context: Context): Partial | undefined; /** * Sets the session ID in the given OpenTelemetry context. * If OI tracer is used in spans created during this active context, the session ID will be added to the span as an attribute. * @param context - The context to set the session ID on. * @param session - The session to set on the context. * @returns The context * @example * ```typescript * context.with( * setSession(context.active(), { sessionId: "session-123" }), * () => { * // Spans created here will have session ID attribute * } * ); * ``` */ export declare function setSession(context: Context, session: Session): Context; export declare function clearSession(context: Context): Context; /** * Retrieves the session ID from the given context. * @param context - The context object. * @returns {string | undefined} The session ID if it exists, otherwise undefined. */ export declare function getSession(context: Context): Session | undefined; /** * Sets the metadata in the given OpenTelemetry context. * If OI tracer is used in spans created during this active context, the metadata will be added to the span as an attribute. * @param context - The context to set the metadata on. * @param metadata - The metadata to set on the context. * @returns The context * @example * ```typescript * context.with( * setMetadata(context.active(), { key: "value", numeric: 1 }), * () => { * // Spans created here will have metadata attribute * } * ); * ``` */ export declare function setMetadata(context: Context, metadata: Metadata): Context; /** * Clears the metadata from the given OpenTelemetry context. * @param context - The context to clear the metadata from. * @returns The context */ export declare function clearMetadata(context: Context): Context; /** * Gets the metadata from the given OpenTelemetry context. * @param context - The context to get the metadata from. * @returns The metadata * @example const metadata = getMetadata(context.active()); */ export declare function getMetadata(context: Context): Metadata | undefined; /** * Sets the user ID in the given OpenTelemetry context. * @param context - The context to set the user ID on. * @param user - The user to set on the context. * @returns The context * @example * ```typescript * context.with( * setUser(context.active(), { userId: "user-123" }), * () => { * // Spans created here will have user ID attribute * } * ); * ``` */ export declare function setUser(context: Context, user: User): Context; /** * Clears the user ID from the given OpenTelemetry context. * @param context - The context to clear the user ID from. * @returns The context */ export declare function clearUser(context: Context): Context; /** * Gets the user ID from the given OpenTelemetry context. * @param context - The context to get the user ID from. * @returns The user * @example const user = getUser(context.active()); */ export declare function getUser(context: Context): User | undefined; /** * Sets the tags in the given OpenTelemetry context. * If OI tracer is used in spans created during this active context, the tags will be added to the span as an attribute. * @param context - The context to set the tags on. * @param tags - The tags to set on the context. * @returns The context * @example * ```typescript * context.with( * setTags(context.active(), ["tag1", "tag2"]), * () => { * // Spans created here will have tags attribute * } * ); * ``` */ export declare function setTags(context: Context, tags: Tags): Context; /** * Clears the tags from the given OpenTelemetry context. * @param context - The context to clear the tags from. * @returns The context */ export declare function clearTags(context: Context): Context; /** * Gets the tags from the given OpenTelemetry context. * @param context - The context to get the tags from. * @returns The tags * @example const tags = getTags(context.active()); */ export declare function getTags(context: Context): Tags | undefined; /** * Sets the attributes in the given OpenTelemetry context. * If OI tracer is used in spans created during this active context, the attributes will be added to the span as an attribute. * @param context - The context to set the attributes on. * @param attributes - The attributes to set on the context. * @returns The context * @example * ```typescript * context.with( * setAttributes(context.active(), { custom: "value", test: "attribute" }), * () => { * // Spans created here will have custom attributes * } * ); * ``` */ export declare function setAttributes(context: Context, attributes: Attributes): Context; /** * Clears the attributes from the given OpenTelemetry context. * @param context - The context to clear the attributes from. * @returns The context */ export declare function clearAttributes(context: Context): Context; /** * Gets the attributes from the given OpenTelemetry context. * @param context - The context to get the attributes from. * @returns The attributes * @example const attributes = getAttributes(context.active()); */ export declare function getAttributes(context: Context): Attributes | undefined; /** * Gets the OpenInference attributes from the given context * @param context * @example * ```typescript * // Chaining multiple attributes * context.with( * setSession( * setPromptTemplate(context.active(), { * template: "hello {name}", * variables: { name: "world" }, * version: "V1.0" * }), * { sessionId: "session-123" } * ), * () => { * // Extract all attributes for span * const attributes = getAttributesFromContext(context.active()); * span.setAttributes(attributes); * } * ); * ``` * @returns {Attributes} The OpenInference attributes formatted as OpenTelemetry span attributes. */ export declare function getAttributesFromContext(context: Context): Attributes; //# sourceMappingURL=contextAttributes.d.ts.map