import { FilterState } from "../../types"; import { TraceRecordReadType } from "./definitions"; import { UiColumnMappings } from "../../tableDefinitions"; import { PreferredClickhouseService } from "../clickhouse/client"; import { ClickHouseClientConfigOptions } from "@clickhouse/client"; import { RenderingProps } from "../utils/rendering"; declare enum TracesAMTs { Traces7dAMT = "traces_7d_amt",// eslint-disable-line no-unused-vars Traces30dAMT = "traces_30d_amt",// eslint-disable-line no-unused-vars TracesAllAMT = "traces_all_amt" } /** * Returns which AMT table to use given the timestamp. * For <= 6 days, we use traces_7d_amt, * for <= 29 days, we use traces_30d_amt, * for all other cases we use traces_all_amt. * * If LANGFUSE_EXPERIMENT_WHITELISTED_AMT_TABLES is set, we only return timeframes * that are whitelisted or fallback to the traces_all_amt. * * @param fromTimestamp */ export declare const getTimeframesTracesAMT: (fromTimestamp: Date | undefined) => TracesAMTs; /** * Checks if trace exists in clickhouse. * Additionally, give back the timestamp of the trace as metadata. * * @param {string} projectId - Project ID for the trace * @param {string} traceId - ID of the trace to check * @param {Date} timestamp - Timestamp for time-based filtering, uses event payload or job timestamp * @param {FilterState} filter - Filter for the trace * @param {Date} maxTimeStamp - Upper bound on timestamp * @param {Date} exactTimestamp - Exact match for the trace * @returns {Promise} - True if trace exists * * Notes: * • Filters within ±2 day window * • Used for validating trace references before eval job creation */ export declare const checkTraceExistsAndGetTimestamp: ({ projectId, traceId, timestamp, filter, maxTimeStamp, exactTimestamp, }: { projectId: string; traceId: string; timestamp: Date; filter: FilterState; maxTimeStamp: Date | undefined; exactTimestamp?: Date; }) => Promise<{ exists: boolean; timestamp?: Date; }>; /** * Accepts a trace in a Clickhouse-ready format. * id, project_id, and timestamp must always be provided. */ export declare const upsertTrace: (trace: Partial) => Promise; export declare const getTracesByIds: (traceIds: string[], projectId: string, timestamp?: Date, clickhouseConfigs?: ClickHouseClientConfigOptions | undefined) => Promise<{ id: string; name: string | null; timestamp: Date; environment: string; tags: string[]; bookmarked: boolean; public: boolean; release: string | null; version: string | null; input: (string | number | boolean | { [key: string]: import("../..").JsonNested; } | import("../..").JsonNested[]) | null; output: (string | number | boolean | { [key: string]: import("../..").JsonNested; } | import("../..").JsonNested[]) | null; metadata: Record; createdAt: Date; updatedAt: Date; sessionId: string | null; userId: string | null; projectId: string; }[]>; export declare const getTracesBySessionId: (projectId: string, sessionIds: string[], timestamp?: Date) => Promise<{ id: string; name: string | null; timestamp: Date; environment: string; tags: string[]; bookmarked: boolean; public: boolean; release: string | null; version: string | null; input: (string | number | boolean | { [key: string]: import("../..").JsonNested; } | import("../..").JsonNested[]) | null; output: (string | number | boolean | { [key: string]: import("../..").JsonNested; } | import("../..").JsonNested[]) | null; metadata: Record; createdAt: Date; updatedAt: Date; sessionId: string | null; userId: string | null; projectId: string; }[]>; export declare const hasAnyTrace: (projectId: string) => Promise; export declare const getTraceCountsByProjectInCreationInterval: ({ start, end, }: { start: Date; end: Date; }) => Promise<{ projectId: string; count: number; }[]>; export declare const getTraceCountOfProjectsSinceCreationDate: ({ projectIds, start, }: { projectIds: string[]; start: Date; }) => Promise; /** * Retrieves a trace record by its ID and associated project ID, with optional filtering by timestamp range. * If no timestamp filters are provided, runs two queries in parallel: * 1. One with a 7-day fromTimestamp filter (typically faster) * 2. One without any timestamp filters (complete but slower) * Returns the first non-empty result. */ export declare const getTraceById: ({ traceId, projectId, timestamp, fromTimestamp, renderingProps, clickhouseFeatureTag, preferredClickhouseService, }: { traceId: string; projectId: string; timestamp?: Date; fromTimestamp?: Date; renderingProps?: RenderingProps; clickhouseFeatureTag?: string; preferredClickhouseService?: PreferredClickhouseService; }) => Promise<{ id: string; name: string | null; timestamp: Date; environment: string; tags: string[]; bookmarked: boolean; public: boolean; release: string | null; version: string | null; input: (string | number | boolean | { [key: string]: import("../..").JsonNested; } | import("../..").JsonNested[]) | null; output: (string | number | boolean | { [key: string]: import("../..").JsonNested; } | import("../..").JsonNested[]) | null; metadata: Record; createdAt: Date; updatedAt: Date; sessionId: string | null; userId: string | null; projectId: string; } | undefined>; export declare const getTracesGroupedByName: (projectId: string, tableDefinitions?: UiColumnMappings, timestampFilter?: FilterState) => Promise<{ name: string; count: string; }[]>; export declare const getTracesGroupedByUsers: (projectId: string, filter: FilterState, searchQuery?: string, limit?: number, offset?: number, columns?: UiColumnMappings) => Promise<{ user: string; count: string; }[]>; export type GroupedTracesQueryProp = { projectId: string; filter: FilterState; columns?: UiColumnMappings; }; export declare const getTracesGroupedByTags: (props: GroupedTracesQueryProp) => Promise<{ value: string; }[]>; export declare const getTracesIdentifierForSession: (projectId: string, sessionId: string) => Promise<{ id: string; userId: string; name: string; timestamp: Date; environment: string; }[]>; export declare const deleteTraces: (projectId: string, traceIds: string[]) => Promise; export declare const deleteTracesOlderThanDays: (projectId: string, beforeDate: Date) => Promise; export declare const deleteTracesByProjectId: (projectId: string) => Promise; export declare const hasAnyUser: (projectId: string) => Promise; export declare const getTotalUserCount: (projectId: string, filter: FilterState, searchQuery?: string) => Promise<{ totalCount: bigint; }[]>; export declare const getUserMetrics: (projectId: string, userIds: string[], filter: FilterState) => Promise<{ userId: string; environment: string; maxTimestamp: Date; minTimestamp: Date; inputUsage: number; outputUsage: number; totalUsage: number; observationCount: number; traceCount: number; totalCost: number; }[]>; export declare const getTracesForBlobStorageExport: (projectId: string, minTimestamp: Date, maxTimestamp: Date) => AsyncGenerator, any, any>; export declare const getTracesForPostHog: (projectId: string, minTimestamp: Date, maxTimestamp: Date) => AsyncGenerator<{ $set: { langfuse_user_url: string; }; timestamp: unknown; langfuse_id: unknown; langfuse_trace_name: unknown; langfuse_url: string; langfuse_cost_usd: unknown; langfuse_count_observations: unknown; langfuse_session_id: unknown; langfuse_project_id: string; langfuse_user_id: {} | null; langfuse_latency: unknown; langfuse_release: unknown; langfuse_version: unknown; langfuse_tags: unknown; langfuse_environment: unknown; langfuse_event_version: string; $session_id: {} | null; } | { $process_person_profile: boolean; timestamp: unknown; langfuse_id: unknown; langfuse_trace_name: unknown; langfuse_url: string; langfuse_cost_usd: unknown; langfuse_count_observations: unknown; langfuse_session_id: unknown; langfuse_project_id: string; langfuse_user_id: {} | null; langfuse_latency: unknown; langfuse_release: unknown; langfuse_version: unknown; langfuse_tags: unknown; langfuse_environment: unknown; langfuse_event_version: string; $session_id: {} | null; }, void, unknown>; /** * This query is used only for legacy support of redirects without a projectId. * We don't have an index on the traceId so it will be a full table scan. * We expect at most 10s of calls per day, so this is acceptable. */ export declare const getTracesByIdsForAnyProject: (traceIds: string[]) => Promise<{ id: string; projectId: string; }[]>; export declare function getAgentGraphData(params: { projectId: string; traceId: string; chMinStartTime: string; chMaxStartTime: string; }): Promise; export {}; //# sourceMappingURL=traces.d.ts.map