/** * Postgres v-next observability storage domain. * * Insert-only model. Mirrors the ClickHouse v-next layout but adapted for * Postgres semantics: * - per-signal partitioned tables (or Timescale hypertables when the * extension is detected) * - retry idempotency via `ON CONFLICT DO NOTHING` on the partition-aware * primary key (the ClickHouse design uses ReplacingMergeTree dedupeKey) * - root-span reads served by partial indexes on the span events table * - discovery values cached in a Postgres table with stale-while-revalidate * semantics, so cache state survives serverless restarts and works * across multiple frontends pointing at the same DB * * IMPORTANT: this domain is intended for **low-volume production** workloads * only. Customers running more than ~100 calls/sec sustained should use the * ClickHouse adapter. See `observability/postgres-design/recommendation.md` * for the volume math behind this guidance. * * The adapter should NOT share a database with the customer's primary * application database — observability writes will degrade app performance. * Use it through `MastraCompositeStore` with a dedicated Postgres connection. */ import { ObservabilityStorage } from '@mastra/core/storage'; import type { BatchCreateFeedbackArgs, BatchCreateLogsArgs, BatchCreateMetricsArgs, BatchCreateScoresArgs, BatchCreateSpansArgs, BatchDeleteTracesArgs, CreateFeedbackArgs, CreateScoreArgs, DeleteFeedbackArgs, DeleteScoresArgs, CreateSpanArgs, GetEntityNamesArgs, GetEntityNamesResponse, GetEntityTypesArgs, GetEntityTypesResponse, GetEnvironmentsArgs, GetEnvironmentsResponse, GetFeedbackAggregateArgs, GetFeedbackAggregateResponse, GetFeedbackBreakdownArgs, GetFeedbackBreakdownResponse, GetFeedbackPercentilesArgs, GetFeedbackPercentilesResponse, GetFeedbackTimeSeriesArgs, GetFeedbackTimeSeriesResponse, GetMetricAggregateArgs, GetMetricAggregateResponse, GetMetricBreakdownArgs, GetMetricBreakdownResponse, GetMetricLabelKeysArgs, GetMetricLabelKeysResponse, GetMetricLabelValuesArgs, GetMetricLabelValuesResponse, GetMetricNamesArgs, GetMetricNamesResponse, GetMetricPercentilesArgs, GetMetricPercentilesResponse, GetMetricTimeSeriesArgs, GetMetricTimeSeriesResponse, GetRootSpanArgs, GetRootSpanResponse, GetSpansArgs, GetSpansResponse, GetScoreAggregateArgs, GetScoreAggregateResponse, GetScoreBreakdownArgs, GetScoreBreakdownResponse, GetScorePercentilesArgs, GetScorePercentilesResponse, GetScoreTimeSeriesArgs, GetScoreTimeSeriesResponse, GetServiceNamesArgs, GetServiceNamesResponse, GetSpanArgs, GetSpanResponse, GetTagsArgs, GetTagsResponse, GetTraceArgs, GetTraceLightResponse, GetTraceResponse, ListBranchesArgs, ListBranchesResponse, ListFeedbackArgs, ListFeedbackResponse, FeedbackRecord, UpdateFeedbackReviewStatusArgs, ListLogsArgs, ListLogsResponse, ListMetricsArgs, ListMetricsResponse, ListScoresArgs, ListScoresResponse, ListTracesArgs, ListTracesResponse, ObservabilityStorageStrategy, PruneOptions, PruneResult, RetentionTablesDescriptor, QueryThreadsResult, ScoreRecord, TableRetentionPolicy, TraceQueryResponse, TrustedThreadQueryPlan, TrustedTraceQueryPlan } from '@mastra/core/storage'; import type { PgDomainConfig } from '../../../db/index.js'; import type { DiscoveryConfig } from './discovery.js'; import type { PartitioningOptions, PartitionMode } from './partitioning.js'; export type { PartitionMode, PartitioningOptions } from './partitioning.js'; export type { DiscoveryConfig } from './discovery.js'; /** Configuration for the v-next Postgres observability domain. */ export type VNextPostgresObservabilityConfig = PgDomainConfig & { /** Daily-partition / Timescale hypertable behavior. Default 'auto'. */ partitioning?: PartitioningOptions; /** Discovery cache configuration. */ discovery?: DiscoveryConfig; /** Maximum execution time for one advanced trace query. Default 15 seconds. */ traceQueryTimeoutMs?: number; }; export declare class ObservabilityStoragePostgresVNext extends ObservabilityStorage { #private; constructor(config: VNextPostgresObservabilityConfig); /** * Create the signal tables, indexes, and (if Timescale / pg_partman is * present) hypertable / partman registrations. * * Not transactional: each `CREATE TABLE IF NOT EXISTS`, `CREATE INDEX IF * NOT EXISTS`, and `create_hypertable()` / `create_parent()` runs in its * own implicit transaction. Re-running `init()` after a failure is safe * (every statement is idempotent), but a failure partway through against * Timescale can leave some signal tables as hypertables and others as * plain tables. If that happens, fix the underlying error and call * `init()` again — the partially-converted state is recoverable. */ init(): Promise; /** Resolved partition mode after init(). Useful for tests and diagnostics. */ get partitionMode(): PartitionMode | undefined; /** * All five signal tables are insert-only growth tables. The anchor column is * each table's partition / chunk key, so age-based expiry drops whole day * partitions instead of deleting rows (see `./retention.ts`). `indexed: true` * reflects that expiry never scans — it acts on partition bounds. */ static readonly retentionTables: RetentionTablesDescriptor; /** * Expire signal events older than each table's `maxAge` by dropping whole * day partitions (native / pg_partman) or chunks (Timescale). Only * partitions wholly older than the cutoff are dropped, so the effective * granularity is one day. Each partition drop counts as one batch for * `maxBatches` / `maxRows` / abort-signal purposes; `deleted` reports the * row count of the dropped partitions. */ prune(policies: Record, options?: PruneOptions): Promise; get observabilityStrategy(): { preferred: ObservabilityStorageStrategy; supported: ObservabilityStorageStrategy[]; }; getFeatures(): readonly ["metrics", "logs", "trace-query", "thread-query"] | readonly ["metrics", "logs", "delta-polling", "trace-query", "thread-query"]; createSpan(args: CreateSpanArgs): Promise; batchCreateSpans(args: BatchCreateSpansArgs): Promise; getSpan(args: GetSpanArgs): Promise; getSpans(args: GetSpansArgs): Promise; getRootSpan(args: GetRootSpanArgs): Promise; getTrace(args: GetTraceArgs): Promise; getTraceLight(args: GetTraceArgs): Promise; listTraces(args: ListTracesArgs): Promise; queryTraces(plan: TrustedTraceQueryPlan): Promise; queryThreads(plan: TrustedThreadQueryPlan): Promise; listBranches(args: ListBranchesArgs): Promise; batchCreateLogs(args: BatchCreateLogsArgs): Promise; batchCreateMetrics(args: BatchCreateMetricsArgs): Promise; createScore(args: CreateScoreArgs): Promise; batchCreateScores(args: BatchCreateScoresArgs): Promise; createFeedback(args: CreateFeedbackArgs): Promise; batchCreateFeedback(args: BatchCreateFeedbackArgs): Promise; deleteScores(args: DeleteScoresArgs): Promise; deleteFeedback(args: DeleteFeedbackArgs): Promise; listLogs(args: ListLogsArgs): Promise; listMetrics(args: ListMetricsArgs): Promise; listScores(args: ListScoresArgs): Promise; getScoreById(scoreId: string): Promise; listFeedback(args: ListFeedbackArgs): Promise; updateFeedbackReviewStatus(args: UpdateFeedbackReviewStatusArgs): Promise; getMetricAggregate(args: GetMetricAggregateArgs): Promise; getMetricBreakdown(args: GetMetricBreakdownArgs): Promise; getMetricTimeSeries(args: GetMetricTimeSeriesArgs): Promise; getMetricPercentiles(args: GetMetricPercentilesArgs): Promise; getScoreAggregate(args: GetScoreAggregateArgs): Promise; getScoreBreakdown(args: GetScoreBreakdownArgs): Promise; getScoreTimeSeries(args: GetScoreTimeSeriesArgs): Promise; getScorePercentiles(args: GetScorePercentilesArgs): Promise; getFeedbackAggregate(args: GetFeedbackAggregateArgs): Promise; getFeedbackBreakdown(args: GetFeedbackBreakdownArgs): Promise; getFeedbackTimeSeries(args: GetFeedbackTimeSeriesArgs): Promise; getFeedbackPercentiles(args: GetFeedbackPercentilesArgs): Promise; getEntityTypes(args: GetEntityTypesArgs): Promise; getEntityNames(args: GetEntityNamesArgs): Promise; getServiceNames(args: GetServiceNamesArgs): Promise; getEnvironments(args: GetEnvironmentsArgs): Promise; getTags(args: GetTagsArgs): Promise; getMetricNames(args: GetMetricNamesArgs): Promise; getMetricLabelKeys(args: GetMetricLabelKeysArgs): Promise; getMetricLabelValues(args: GetMetricLabelValuesArgs): Promise; batchDeleteTraces(args: BatchDeleteTracesArgs): Promise; dangerouslyClearAll(): Promise; } //# sourceMappingURL=index.d.ts.map