@mastra/observability 1.5.1 → 1.6.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/dist/bus/observability-bus.d.ts +4 -21
- package/dist/bus/observability-bus.d.ts.map +1 -1
- package/dist/context/logger.d.ts +6 -10
- package/dist/context/logger.d.ts.map +1 -1
- package/dist/context/metrics.d.ts +18 -11
- package/dist/context/metrics.d.ts.map +1 -1
- package/dist/exporters/test.d.ts.map +1 -1
- package/dist/index.cjs +701 -267
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +698 -268
- package/dist/index.js.map +1 -1
- package/dist/instances/base.d.ts +6 -22
- package/dist/instances/base.d.ts.map +1 -1
- package/dist/metrics/auto-extract.d.ts +8 -28
- package/dist/metrics/auto-extract.d.ts.map +1 -1
- package/dist/metrics/estimator.d.ts +9 -0
- package/dist/metrics/estimator.d.ts.map +1 -0
- package/dist/metrics/index.d.ts +0 -1
- package/dist/metrics/index.d.ts.map +1 -1
- package/dist/metrics/pricing-data.jsonl +4682 -0
- package/dist/metrics/pricing-model.d.ts +43 -0
- package/dist/metrics/pricing-model.d.ts.map +1 -0
- package/dist/metrics/pricing-registry.d.ts +13 -0
- package/dist/metrics/pricing-registry.d.ts.map +1 -0
- package/dist/metrics/types.d.ts +29 -0
- package/dist/metrics/types.d.ts.map +1 -0
- package/dist/metrics/usage-metrics.d.ts +8 -0
- package/dist/metrics/usage-metrics.d.ts.map +1 -0
- package/dist/spans/base.d.ts +5 -1
- package/dist/spans/base.d.ts.map +1 -1
- package/dist/usage.d.ts.map +1 -1
- package/package.json +7 -7
package/dist/instances/base.d.ts
CHANGED
|
@@ -96,19 +96,6 @@ export declare abstract class BaseObservabilityInstance extends MastraBase imple
|
|
|
96
96
|
* to registered exporters based on event type.
|
|
97
97
|
*/
|
|
98
98
|
getObservabilityBus(): ObservabilityBus;
|
|
99
|
-
/**
|
|
100
|
-
* Extract entity context labels from a span's entity hierarchy by
|
|
101
|
-
* walking the parent chain.
|
|
102
|
-
*
|
|
103
|
-
* Returns labels for: entity_type/name, parent_type/name, root_type/name.
|
|
104
|
-
* Internal spans are skipped when resolving parent and root entities.
|
|
105
|
-
*/
|
|
106
|
-
private extractEntityLabels;
|
|
107
|
-
/**
|
|
108
|
-
* Resolve tags for a span. Uses the span's own tags if present,
|
|
109
|
-
* otherwise walks to the root span to inherit its tags.
|
|
110
|
-
*/
|
|
111
|
-
private resolveSpanTags;
|
|
112
99
|
/**
|
|
113
100
|
* Get a LoggerContext correlated to a span.
|
|
114
101
|
* Called by the context-factory in core (deriveLoggerContext) so that
|
|
@@ -116,7 +103,7 @@ export declare abstract class BaseObservabilityInstance extends MastraBase imple
|
|
|
116
103
|
*/
|
|
117
104
|
getLoggerContext(span?: AnySpan): LoggerContext;
|
|
118
105
|
/**
|
|
119
|
-
* Get a MetricsContext
|
|
106
|
+
* Get a MetricsContext correlated to a span.
|
|
120
107
|
* Called by the context-factory in core (deriveMetricsContext) so that
|
|
121
108
|
* `observabilityContext.metrics` is a real metrics context instead of no-op.
|
|
122
109
|
*/
|
|
@@ -156,28 +143,25 @@ export declare abstract class BaseObservabilityInstance extends MastraBase imple
|
|
|
156
143
|
getSpanForExport(span: AnySpan): AnyExportedSpan | undefined;
|
|
157
144
|
/**
|
|
158
145
|
* Emit a span started event.
|
|
159
|
-
* Routes through the ObservabilityBus so exporters receive it via onTracingEvent
|
|
160
|
-
* and auto-extracted metrics are generated.
|
|
146
|
+
* Routes through the ObservabilityBus so exporters receive it via onTracingEvent.
|
|
161
147
|
*/
|
|
162
148
|
protected emitSpanStarted(span: AnySpan): void;
|
|
163
149
|
/**
|
|
164
150
|
* Emit a span ended event (called automatically when spans end).
|
|
165
|
-
*
|
|
166
|
-
*
|
|
151
|
+
* Emits any auto-extracted metrics while the live span tree is still available,
|
|
152
|
+
* then routes the exported tracing event through the ObservabilityBus.
|
|
167
153
|
*/
|
|
168
154
|
protected emitSpanEnded(span: AnySpan): void;
|
|
169
155
|
/**
|
|
170
156
|
* Emit a span updated event.
|
|
171
|
-
* Routes through the ObservabilityBus so exporters receive it via onTracingEvent
|
|
172
|
-
* and auto-extracted metrics are generated.
|
|
157
|
+
* Routes through the ObservabilityBus so exporters receive it via onTracingEvent.
|
|
173
158
|
*/
|
|
174
159
|
protected emitSpanUpdated(span: AnySpan): void;
|
|
175
160
|
/**
|
|
176
161
|
* Emit a tracing event through the bus.
|
|
177
162
|
*
|
|
178
163
|
* The bus routes the event to each registered exporter's and bridge's
|
|
179
|
-
* onTracingEvent handler
|
|
180
|
-
* mastra_agent_duration_ms, mastra_model_duration_ms).
|
|
164
|
+
* onTracingEvent handler.
|
|
181
165
|
*/
|
|
182
166
|
private emitTracingEvent;
|
|
183
167
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../src/instances/base.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAGzD,OAAO,KAAK,EACV,IAAI,EACJ,qBAAqB,EACrB,mBAAmB,EACnB,mBAAmB,EACnB,YAAY,EACZ,OAAO,EAGP,gBAAgB,EAChB,iBAAiB,EACjB,qBAAqB,EACrB,oBAAoB,EACpB,YAAY,EACZ,eAAe,EACf,UAAU,EACV,cAAc,EACd,aAAa,EACb,cAAc,EACd,kBAAkB,EAClB,QAAQ,EACT,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EAAE,gBAAgB,EAAE,MAAM,QAAQ,CAAC;AAC1C,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../src/instances/base.ts"],"names":[],"m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,CAAC,WAAW,CAAC,cAAc,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IA2B1F;;OAEG;IACH,OAAO,CAAC,WAAW;IAqBnB,mGAAmG;IACnG,gBAAgB,CAAC,IAAI,EAAE,OAAO,GAAG,eAAe,GAAG,SAAS;IAQ5D;;;OAGG;IACH,SAAS,CAAC,eAAe,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI;IAQ9C;;;;OAIG;IACH,SAAS,CAAC,aAAa,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI;IAuB5C;;;OAGG;IACH,SAAS,CAAC,eAAe,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI;IAQ9C;;;;;OAKG;IACH,OAAO,CAAC,gBAAgB;IAIxB;;;;;OAKG;cACa,kBAAkB,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IA6BtE;;OAEG;IACH,IAAI,IAAI,IAAI;IASZ;;;;;;;;;OASG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAM5B;;OAEG;IACG,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;CAyBhC"}
|
|
@@ -1,31 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
* When a tracing span ends, this class emits metric events for duration
|
|
5
|
-
* and token usage (for model spans).
|
|
2
|
+
* Emits metrics derived from live spans.
|
|
6
3
|
*/
|
|
7
|
-
import type {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
export declare class AutoExtractedMetrics {
|
|
15
|
-
private observabilityBus;
|
|
16
|
-
constructor(observabilityBus: ObservabilityBus);
|
|
17
|
-
/**
|
|
18
|
-
* Route a tracing event to the appropriate handler.
|
|
19
|
-
* SPAN_ENDED emits duration and token metrics (for model spans).
|
|
20
|
-
*/
|
|
21
|
-
processTracingEvent(event: TracingEvent): void;
|
|
22
|
-
/** Emit duration and token metrics when a span ends. */
|
|
23
|
-
private onSpanEnded;
|
|
24
|
-
/** Build base metric labels from a span's entity and model attributes. */
|
|
25
|
-
private extractLabels;
|
|
26
|
-
/** Emit token usage metrics from UsageStats. */
|
|
27
|
-
private extractTokenMetrics;
|
|
28
|
-
/** Map a span type to its `*_duration_ms` metric name, or `null` for unsupported types. */
|
|
29
|
-
private getDurationMetricName;
|
|
30
|
-
}
|
|
4
|
+
import type { AnySpan, MetricsContext } from '@mastra/core/observability';
|
|
5
|
+
/** Emit duration metrics for a live span. */
|
|
6
|
+
export declare function emitDurationMetrics(span: AnySpan, metrics: MetricsContext): void;
|
|
7
|
+
/** Emit token usage metrics for a model-generation span. */
|
|
8
|
+
export declare function emitTokenMetrics(span: AnySpan, metrics: MetricsContext): void;
|
|
9
|
+
/** Emit all auto-extracted metrics for a live span end. */
|
|
10
|
+
export declare function emitAutoExtractedMetrics(span: AnySpan, metrics: MetricsContext): void;
|
|
31
11
|
//# sourceMappingURL=auto-extract.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auto-extract.d.ts","sourceRoot":"","sources":["../../src/metrics/auto-extract.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"auto-extract.d.ts","sourceRoot":"","sources":["../../src/metrics/auto-extract.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,KAAK,EAAE,OAAO,EAAe,cAAc,EAA6B,MAAM,4BAA4B,CAAC;AAKlH,6CAA6C;AAC7C,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,cAAc,GAAG,IAAI,CAUhF;AAED,4DAA4D;AAC5D,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,cAAc,GAAG,IAAI,CAW7E;AAED,2DAA2D;AAC3D,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,cAAc,GAAG,IAAI,CAGrF"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { CostContext, UsageStats } from '@mastra/core/observability';
|
|
2
|
+
import { PricingRegistry } from './pricing-registry.js';
|
|
3
|
+
import { TokenMetrics } from './types.js';
|
|
4
|
+
export declare function estimateCosts(args: {
|
|
5
|
+
provider: string;
|
|
6
|
+
model: string;
|
|
7
|
+
usage: UsageStats;
|
|
8
|
+
}, pricingRegistry?: PricingRegistry | null): Map<TokenMetrics, CostContext>;
|
|
9
|
+
//# sourceMappingURL=estimator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"estimator.d.ts","sourceRoot":"","sources":["../../src/metrics/estimator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAE1E,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAgB,MAAM,SAAS,CAAC;AAGrD,wBAAgB,aAAa,CAC3B,IAAI,EAAE;IACJ,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,UAAU,CAAC;CACnB,EACD,eAAe,GAAE,eAAe,GAAG,IAAkC,GACpE,GAAG,CAAC,YAAY,EAAE,WAAW,CAAC,CAyIhC"}
|
package/dist/metrics/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/metrics/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/metrics/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC"}
|