@mastra/observability 0.0.0-studio-deploy-20260403185613 → 0.0.0-studio-deploy-20260403231316
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 +51 -3
- package/dist/default.d.ts +5 -3
- package/dist/default.d.ts.map +1 -1
- package/dist/exporters/test.d.ts.map +1 -1
- package/dist/index.cjs +115 -53
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +115 -53
- package/dist/index.js.map +1 -1
- package/dist/metrics/pricing-registry.d.ts.map +1 -1
- package/dist/recorded.d.ts +12 -13
- package/dist/recorded.d.ts.map +1 -1
- package/dist/spans/base.d.ts +2 -0
- package/dist/spans/base.d.ts.map +1 -1
- package/dist/spans/default.d.ts.map +1 -1
- package/dist/usage.d.ts.map +1 -1
- package/package.json +7 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,11 +1,59 @@
|
|
|
1
1
|
# @mastra/observability
|
|
2
2
|
|
|
3
|
-
## 0.0.0-studio-deploy-
|
|
3
|
+
## 0.0.0-studio-deploy-20260403231316
|
|
4
4
|
|
|
5
5
|
### Patch Changes
|
|
6
6
|
|
|
7
|
-
- Updated dependencies [[`c55b527`](https://github.com/mastra-ai/mastra/commit/c55b52758a31368b2077b0dbbc3badfe4063f560)]:
|
|
8
|
-
- @mastra/core@0.0.0-studio-deploy-
|
|
7
|
+
- Updated dependencies [[`c55b527`](https://github.com/mastra-ai/mastra/commit/c55b52758a31368b2077b0dbbc3badfe4063f560), [`7eb2596`](https://github.com/mastra-ai/mastra/commit/7eb25960d607e07468c9a10c5437abd2deaf1e9a)]:
|
|
8
|
+
- @mastra/core@0.0.0-studio-deploy-20260403231316
|
|
9
|
+
|
|
10
|
+
## 1.7.2
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- **Fixed Anthropic cache tokens being double-counted in observability metrics** ([#13914](https://github.com/mastra-ai/mastra/pull/13914))
|
|
15
|
+
|
|
16
|
+
Anthropic cache token usage is now normalized correctly for AI SDK v6-style usage payloads, so input token metrics and tracing output no longer overcount cached tokens when the total already includes them.
|
|
17
|
+
|
|
18
|
+
- Updated dependencies [[`cb15509`](https://github.com/mastra-ai/mastra/commit/cb15509b58f6a83e11b765c945082afc027db972), [`81e4259`](https://github.com/mastra-ai/mastra/commit/81e425939b4ceeb4f586e9b6d89c3b1c1f2d2fe7), [`951b8a1`](https://github.com/mastra-ai/mastra/commit/951b8a1b5ef7e1474c59dc4f2b9fc1a8b1e508b6), [`80c5668`](https://github.com/mastra-ai/mastra/commit/80c5668e365470d3a96d3e953868fd7a643ff67c), [`3d478c1`](https://github.com/mastra-ai/mastra/commit/3d478c1e13f17b80f330ac49d7aa42ef929b93ff), [`2b4ea10`](https://github.com/mastra-ai/mastra/commit/2b4ea10b053e4ea1ab232d536933a4a3c4cba999), [`a0544f0`](https://github.com/mastra-ai/mastra/commit/a0544f0a1e6bd52ac12676228967c1938e43648d), [`6039f17`](https://github.com/mastra-ai/mastra/commit/6039f176f9c457304825ff1df8c83b8e457376c0), [`06b928d`](https://github.com/mastra-ai/mastra/commit/06b928dfc2f5630d023467476cc5919dfa858d0a), [`6a8d984`](https://github.com/mastra-ai/mastra/commit/6a8d9841f2933456ee1598099f488d742b600054), [`c8c86aa`](https://github.com/mastra-ai/mastra/commit/c8c86aa1458017fbd1c0776fdc0c520d129df8a6)]:
|
|
19
|
+
- @mastra/core@1.22.0
|
|
20
|
+
|
|
21
|
+
## 1.7.2-alpha.0
|
|
22
|
+
|
|
23
|
+
### Patch Changes
|
|
24
|
+
|
|
25
|
+
- **Fixed Anthropic cache tokens being double-counted in observability metrics** ([#13914](https://github.com/mastra-ai/mastra/pull/13914))
|
|
26
|
+
|
|
27
|
+
Anthropic cache token usage is now normalized correctly for AI SDK v6-style usage payloads, so input token metrics and tracing output no longer overcount cached tokens when the total already includes them.
|
|
28
|
+
|
|
29
|
+
- Updated dependencies [[`81e4259`](https://github.com/mastra-ai/mastra/commit/81e425939b4ceeb4f586e9b6d89c3b1c1f2d2fe7), [`951b8a1`](https://github.com/mastra-ai/mastra/commit/951b8a1b5ef7e1474c59dc4f2b9fc1a8b1e508b6)]:
|
|
30
|
+
- @mastra/core@1.22.0-alpha.1
|
|
31
|
+
|
|
32
|
+
## 1.7.1
|
|
33
|
+
|
|
34
|
+
### Patch Changes
|
|
35
|
+
|
|
36
|
+
- Fixed score and feedback annotations being dropped before spans flush by emitting from live correlation context when available. Scores and feedback can now also be stored without a trace ID when only contextual metadata is available. ([#14942](https://github.com/mastra-ai/mastra/pull/14942))
|
|
37
|
+
|
|
38
|
+
- Fixed pricing model lookup to fall back to dot-to-dash normalization for model names (e.g. `gpt-5.2` → `gpt-5-2`), resolving `no_matching_model` errors for Azure deployments ([#14959](https://github.com/mastra-ai/mastra/pull/14959))
|
|
39
|
+
|
|
40
|
+
- Added error name and stack trace to SpanErrorInfo, allowing exporters to access the original error class name and stack trace for richer error reporting. ([#14944](https://github.com/mastra-ai/mastra/pull/14944))
|
|
41
|
+
|
|
42
|
+
- Updated dependencies [[`9a43b47`](https://github.com/mastra-ai/mastra/commit/9a43b476465e86c9aca381c2831066b5c33c999a), [`ec5c319`](https://github.com/mastra-ai/mastra/commit/ec5c3197a50d034cb8e9cc494eebfddc684b5d81), [`6517789`](https://github.com/mastra-ai/mastra/commit/65177895b74b5471fe2245c7292f0176d9b3385d), [`13f4327`](https://github.com/mastra-ai/mastra/commit/13f4327f052faebe199cefbe906d33bf90238767), [`9ad6aa6`](https://github.com/mastra-ai/mastra/commit/9ad6aa6dfe858afc6955d1df5f3f78c40bb96b9c), [`2862127`](https://github.com/mastra-ai/mastra/commit/2862127d0a7cbd28523120ad64fea067a95838e6), [`3d16814`](https://github.com/mastra-ai/mastra/commit/3d16814c395931373543728994ff45ac98093074), [`7f498d0`](https://github.com/mastra-ai/mastra/commit/7f498d099eacef64fd43ee412e3bd6f87965a8a6), [`8cf8a67`](https://github.com/mastra-ai/mastra/commit/8cf8a67b061b737cb06d501fb8c1967a98bbf3cb), [`d7827e3`](https://github.com/mastra-ai/mastra/commit/d7827e393937c6cb0c7a744dde4d31538cb542b7)]:
|
|
43
|
+
- @mastra/core@1.21.0
|
|
44
|
+
|
|
45
|
+
## 1.7.1-alpha.0
|
|
46
|
+
|
|
47
|
+
### Patch Changes
|
|
48
|
+
|
|
49
|
+
- Fixed score and feedback annotations being dropped before spans flush by emitting from live correlation context when available. Scores and feedback can now also be stored without a trace ID when only contextual metadata is available. ([#14942](https://github.com/mastra-ai/mastra/pull/14942))
|
|
50
|
+
|
|
51
|
+
- Fixed pricing model lookup to fall back to dot-to-dash normalization for model names (e.g. `gpt-5.2` → `gpt-5-2`), resolving `no_matching_model` errors for Azure deployments ([#14959](https://github.com/mastra-ai/mastra/pull/14959))
|
|
52
|
+
|
|
53
|
+
- Added error name and stack trace to SpanErrorInfo, allowing exporters to access the original error class name and stack trace for richer error reporting. ([#14944](https://github.com/mastra-ai/mastra/pull/14944))
|
|
54
|
+
|
|
55
|
+
- Updated dependencies [[`ec5c319`](https://github.com/mastra-ai/mastra/commit/ec5c3197a50d034cb8e9cc494eebfddc684b5d81), [`6517789`](https://github.com/mastra-ai/mastra/commit/65177895b74b5471fe2245c7292f0176d9b3385d), [`9ad6aa6`](https://github.com/mastra-ai/mastra/commit/9ad6aa6dfe858afc6955d1df5f3f78c40bb96b9c), [`2862127`](https://github.com/mastra-ai/mastra/commit/2862127d0a7cbd28523120ad64fea067a95838e6), [`3d16814`](https://github.com/mastra-ai/mastra/commit/3d16814c395931373543728994ff45ac98093074), [`7f498d0`](https://github.com/mastra-ai/mastra/commit/7f498d099eacef64fd43ee412e3bd6f87965a8a6), [`8cf8a67`](https://github.com/mastra-ai/mastra/commit/8cf8a67b061b737cb06d501fb8c1967a98bbf3cb), [`d7827e3`](https://github.com/mastra-ai/mastra/commit/d7827e393937c6cb0c7a744dde4d31538cb542b7)]:
|
|
56
|
+
- @mastra/core@1.21.0-alpha.2
|
|
9
57
|
|
|
10
58
|
## 1.7.0
|
|
11
59
|
|
package/dist/default.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Mastra } from '@mastra/core';
|
|
2
2
|
import { MastraBase } from '@mastra/core/base';
|
|
3
3
|
import type { IMastraLogger } from '@mastra/core/logger';
|
|
4
|
-
import type { ConfigSelector, ConfigSelectorOptions, FeedbackInput, ObservabilityEntrypoint, ObservabilityInstance, RecordedTrace, ScoreInput } from '@mastra/core/observability';
|
|
4
|
+
import type { CorrelationContext, ConfigSelector, ConfigSelectorOptions, FeedbackInput, ObservabilityEntrypoint, ObservabilityInstance, RecordedTrace, ScoreInput } from '@mastra/core/observability';
|
|
5
5
|
import type { ObservabilityRegistryConfig } from './config.js';
|
|
6
6
|
/**
|
|
7
7
|
* Top-level observability entrypoint. Manages a registry of ObservabilityInstance
|
|
@@ -24,13 +24,15 @@ export declare class Observability extends MastraBase implements ObservabilityEn
|
|
|
24
24
|
traceId: string;
|
|
25
25
|
}): Promise<RecordedTrace | null>;
|
|
26
26
|
addScore(args: {
|
|
27
|
-
traceId
|
|
27
|
+
traceId?: string;
|
|
28
28
|
spanId?: string;
|
|
29
|
+
correlationContext?: CorrelationContext;
|
|
29
30
|
score: ScoreInput;
|
|
30
31
|
}): Promise<void>;
|
|
31
32
|
addFeedback(args: {
|
|
32
|
-
traceId
|
|
33
|
+
traceId?: string;
|
|
33
34
|
spanId?: string;
|
|
35
|
+
correlationContext?: CorrelationContext;
|
|
34
36
|
feedback: FeedbackInput;
|
|
35
37
|
}): Promise<void>;
|
|
36
38
|
/** Register a named observability instance, optionally marking it as default. */
|
package/dist/default.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"default.d.ts","sourceRoot":"","sources":["../src/default.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;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porter {
|
|
|
15968
15968
|
this.#trackEvent("score");
|
|
15969
15969
|
if (this.#config.storeLogs) {
|
|
15970
15970
|
const score = event.score;
|
|
15971
|
-
const
|
|
15971
|
+
const traceLabel = score.traceId ? score.traceId.slice(-8) : "unanchored";
|
|
15972
|
+
const logMessage = `[TestExporter] score: ${score.scorerId}=${score.score} (trace: ${traceLabel}${score.spanId ? `, span: ${score.spanId.slice(-8)}` : ""})`;
|
|
15972
15973
|
this.#debugLogs.push(logMessage);
|
|
15973
15974
|
}
|
|
15974
15975
|
this.#scoreEvents.push(event);
|
|
@@ -15980,7 +15981,9 @@ var TestExporter = class extends BaseExporter {
|
|
|
15980
15981
|
this.#trackEvent("feedback");
|
|
15981
15982
|
if (this.#config.storeLogs) {
|
|
15982
15983
|
const fb = event.feedback;
|
|
15983
|
-
const
|
|
15984
|
+
const traceLabel = fb.traceId ? fb.traceId.slice(-8) : "unanchored";
|
|
15985
|
+
const feedbackSource = fb.feedbackSource ?? fb.source;
|
|
15986
|
+
const logMessage = `[TestExporter] feedback: ${fb.feedbackType} from ${feedbackSource}=${fb.value} (trace: ${traceLabel}${fb.spanId ? `, span: ${fb.spanId.slice(-8)}` : ""})`;
|
|
15984
15987
|
this.#debugLogs.push(logMessage);
|
|
15985
15988
|
}
|
|
15986
15989
|
this.#feedbackEvents.push(event);
|
|
@@ -16130,10 +16133,14 @@ var TestExporter = class extends BaseExporter {
|
|
|
16130
16133
|
if (event.log.traceId) traceIds.add(event.log.traceId);
|
|
16131
16134
|
}
|
|
16132
16135
|
for (const event of this.#scoreEvents) {
|
|
16133
|
-
|
|
16136
|
+
if (event.score.traceId) {
|
|
16137
|
+
traceIds.add(event.score.traceId);
|
|
16138
|
+
}
|
|
16134
16139
|
}
|
|
16135
16140
|
for (const event of this.#feedbackEvents) {
|
|
16136
|
-
|
|
16141
|
+
if (event.feedback.traceId) {
|
|
16142
|
+
traceIds.add(event.feedback.traceId);
|
|
16143
|
+
}
|
|
16137
16144
|
}
|
|
16138
16145
|
return Array.from(traceIds);
|
|
16139
16146
|
}
|
|
@@ -17436,7 +17443,14 @@ var PricingRegistry = class _PricingRegistry {
|
|
|
17436
17443
|
return _PricingRegistry.globalRegistry;
|
|
17437
17444
|
}
|
|
17438
17445
|
get(args) {
|
|
17439
|
-
|
|
17446
|
+
const key = makePricingKey(args);
|
|
17447
|
+
const exact = this.pricingModels.get(key);
|
|
17448
|
+
if (exact) return exact;
|
|
17449
|
+
const dashedKey = makePricingKey({ provider: args.provider, model: args.model.replace(/\./g, "-") });
|
|
17450
|
+
if (dashedKey !== key) {
|
|
17451
|
+
return this.pricingModels.get(dashedKey) ?? null;
|
|
17452
|
+
}
|
|
17453
|
+
return null;
|
|
17440
17454
|
}
|
|
17441
17455
|
};
|
|
17442
17456
|
function loadPricingModels() {
|
|
@@ -17877,6 +17891,9 @@ var CardinalityFilter = class {
|
|
|
17877
17891
|
};
|
|
17878
17892
|
|
|
17879
17893
|
// src/usage.ts
|
|
17894
|
+
function isV3RawUsage(raw) {
|
|
17895
|
+
return typeof raw === "object" && raw !== null && "inputTokens" in raw;
|
|
17896
|
+
}
|
|
17880
17897
|
function isDefined(value) {
|
|
17881
17898
|
return value != null;
|
|
17882
17899
|
}
|
|
@@ -17903,13 +17920,15 @@ function extractUsageMetrics(usage, providerMetadata) {
|
|
|
17903
17920
|
}
|
|
17904
17921
|
const anthropic = providerMetadata?.anthropic;
|
|
17905
17922
|
if (anthropic) {
|
|
17923
|
+
const rawV3InputUsage = isV3RawUsage(usage.raw) ? usage.raw.inputTokens : void 0;
|
|
17924
|
+
const hasV3CachedTotals = rawV3InputUsage?.total !== void 0 && (rawV3InputUsage.cacheRead !== void 0 || rawV3InputUsage.cacheWrite !== void 0);
|
|
17906
17925
|
if (!isDefined(inputDetails.cacheRead) && isDefined(anthropic.cacheReadInputTokens)) {
|
|
17907
17926
|
inputDetails.cacheRead = anthropic.cacheReadInputTokens;
|
|
17908
17927
|
}
|
|
17909
17928
|
if (!isDefined(inputDetails.cacheWrite) && isDefined(anthropic.cacheCreationInputTokens)) {
|
|
17910
17929
|
inputDetails.cacheWrite = anthropic.cacheCreationInputTokens;
|
|
17911
17930
|
}
|
|
17912
|
-
if (isDefined(inputDetails.cacheRead) || isDefined(inputDetails.cacheWrite)) {
|
|
17931
|
+
if (!hasV3CachedTotals && (isDefined(inputDetails.cacheRead) || isDefined(inputDetails.cacheWrite))) {
|
|
17913
17932
|
inputTokens = (usage.inputTokens ?? 0) + (inputDetails.cacheRead ?? 0) + (inputDetails.cacheWrite ?? 0);
|
|
17914
17933
|
}
|
|
17915
17934
|
}
|
|
@@ -18889,15 +18908,22 @@ var DefaultSpan = class extends BaseSpan {
|
|
|
18889
18908
|
return;
|
|
18890
18909
|
}
|
|
18891
18910
|
const { error: error48, endSpan = true, attributes, metadata } = options;
|
|
18892
|
-
this.errorInfo =
|
|
18893
|
-
|
|
18894
|
-
|
|
18895
|
-
|
|
18896
|
-
|
|
18897
|
-
|
|
18898
|
-
|
|
18899
|
-
|
|
18900
|
-
|
|
18911
|
+
this.errorInfo = deepClean(
|
|
18912
|
+
error48 instanceof error$1.MastraError ? {
|
|
18913
|
+
id: error48.id,
|
|
18914
|
+
details: error48.details,
|
|
18915
|
+
category: error48.category,
|
|
18916
|
+
domain: error48.domain,
|
|
18917
|
+
message: error48.message,
|
|
18918
|
+
name: error48.name,
|
|
18919
|
+
stack: error48.stack
|
|
18920
|
+
} : {
|
|
18921
|
+
message: error48.message,
|
|
18922
|
+
name: error48.name,
|
|
18923
|
+
stack: error48.stack
|
|
18924
|
+
},
|
|
18925
|
+
this.deepCleanOptions
|
|
18926
|
+
);
|
|
18901
18927
|
if (attributes) {
|
|
18902
18928
|
this.attributes = { ...this.attributes, ...deepClean(attributes, this.deepCleanOptions) };
|
|
18903
18929
|
}
|
|
@@ -19563,6 +19589,8 @@ function normalizeErrorInfo(error48) {
|
|
|
19563
19589
|
return {
|
|
19564
19590
|
message: error48.message,
|
|
19565
19591
|
id: "id" in error48 && typeof error48.id === "string" ? error48.id : void 0,
|
|
19592
|
+
name: "name" in error48 && typeof error48.name === "string" ? error48.name : void 0,
|
|
19593
|
+
stack: "stack" in error48 && typeof error48.stack === "string" ? error48.stack : void 0,
|
|
19566
19594
|
domain: "domain" in error48 && typeof error48.domain === "string" ? error48.domain : void 0,
|
|
19567
19595
|
category: "category" in error48 && typeof error48.category === "string" ? error48.category : void 0,
|
|
19568
19596
|
details: "details" in error48 && error48.details && typeof error48.details === "object" ? error48.details : void 0
|
|
@@ -19593,13 +19621,13 @@ function buildCorrelationContext(span, rootSpan, parent) {
|
|
|
19593
19621
|
experimentId: nullToUndefined(span.experimentId)
|
|
19594
19622
|
};
|
|
19595
19623
|
}
|
|
19596
|
-
function
|
|
19597
|
-
const {
|
|
19624
|
+
function buildScoreEvent(args) {
|
|
19625
|
+
const { traceId, spanId, correlationContext, score, inheritedMetadata } = args;
|
|
19598
19626
|
return {
|
|
19599
19627
|
type: "score",
|
|
19600
19628
|
score: {
|
|
19601
19629
|
timestamp: /* @__PURE__ */ new Date(),
|
|
19602
|
-
traceId
|
|
19630
|
+
traceId,
|
|
19603
19631
|
spanId,
|
|
19604
19632
|
scorerId: score.scorerId,
|
|
19605
19633
|
scorerVersion: score.scorerVersion,
|
|
@@ -19609,18 +19637,18 @@ function buildRecordedScoreEvent(args) {
|
|
|
19609
19637
|
reason: score.reason,
|
|
19610
19638
|
experimentId: score.experimentId,
|
|
19611
19639
|
scoreTraceId: score.scoreTraceId,
|
|
19612
|
-
correlationContext
|
|
19613
|
-
metadata: mergeMetadata(
|
|
19640
|
+
correlationContext,
|
|
19641
|
+
metadata: mergeMetadata(inheritedMetadata, score.metadata)
|
|
19614
19642
|
}
|
|
19615
19643
|
};
|
|
19616
19644
|
}
|
|
19617
|
-
function
|
|
19618
|
-
const {
|
|
19645
|
+
function buildFeedbackEvent(args) {
|
|
19646
|
+
const { traceId, spanId, correlationContext, feedback, inheritedMetadata } = args;
|
|
19619
19647
|
return {
|
|
19620
19648
|
type: "feedback",
|
|
19621
19649
|
feedback: {
|
|
19622
19650
|
timestamp: /* @__PURE__ */ new Date(),
|
|
19623
|
-
traceId
|
|
19651
|
+
traceId,
|
|
19624
19652
|
spanId,
|
|
19625
19653
|
source: feedback.source,
|
|
19626
19654
|
feedbackSource: feedback.feedbackSource,
|
|
@@ -19631,8 +19659,8 @@ function buildRecordedFeedbackEvent(args) {
|
|
|
19631
19659
|
comment: feedback.comment,
|
|
19632
19660
|
sourceId: feedback.sourceId,
|
|
19633
19661
|
experimentId: feedback.experimentId,
|
|
19634
|
-
correlationContext
|
|
19635
|
-
metadata: mergeMetadata(
|
|
19662
|
+
correlationContext,
|
|
19663
|
+
metadata: mergeMetadata(inheritedMetadata, feedback.metadata)
|
|
19636
19664
|
}
|
|
19637
19665
|
};
|
|
19638
19666
|
}
|
|
@@ -19646,12 +19674,12 @@ function buildRecordedScoreEventFromTrace(args) {
|
|
|
19646
19674
|
const span = args.spanId ? findSpanById(args.trace.spans, args.spanId) : rootSpan;
|
|
19647
19675
|
if (!span) return null;
|
|
19648
19676
|
const parent = span.parentSpanId ? findSpanById(args.trace.spans, span.parentSpanId) : void 0;
|
|
19649
|
-
return
|
|
19650
|
-
span,
|
|
19651
|
-
|
|
19652
|
-
parent,
|
|
19677
|
+
return buildScoreEvent({
|
|
19678
|
+
traceId: span.traceId,
|
|
19679
|
+
spanId: args.spanId,
|
|
19680
|
+
correlationContext: buildCorrelationContext(span, rootSpan, parent),
|
|
19653
19681
|
score: args.score,
|
|
19654
|
-
|
|
19682
|
+
inheritedMetadata: span.metadata
|
|
19655
19683
|
});
|
|
19656
19684
|
}
|
|
19657
19685
|
function buildRecordedFeedbackEventFromTrace(args) {
|
|
@@ -19660,12 +19688,12 @@ function buildRecordedFeedbackEventFromTrace(args) {
|
|
|
19660
19688
|
const span = args.spanId ? findSpanById(args.trace.spans, args.spanId) : rootSpan;
|
|
19661
19689
|
if (!span) return null;
|
|
19662
19690
|
const parent = span.parentSpanId ? findSpanById(args.trace.spans, span.parentSpanId) : void 0;
|
|
19663
|
-
return
|
|
19664
|
-
span,
|
|
19665
|
-
|
|
19666
|
-
parent,
|
|
19691
|
+
return buildFeedbackEvent({
|
|
19692
|
+
traceId: span.traceId,
|
|
19693
|
+
spanId: args.spanId,
|
|
19694
|
+
correlationContext: buildCorrelationContext(span, rootSpan, parent),
|
|
19667
19695
|
feedback: args.feedback,
|
|
19668
|
-
|
|
19696
|
+
inheritedMetadata: span.metadata
|
|
19669
19697
|
});
|
|
19670
19698
|
}
|
|
19671
19699
|
var RecordedSpanImpl = class {
|
|
@@ -19728,12 +19756,12 @@ var RecordedSpanImpl = class {
|
|
|
19728
19756
|
return;
|
|
19729
19757
|
}
|
|
19730
19758
|
await this.#emitRecordedEvent(
|
|
19731
|
-
|
|
19732
|
-
|
|
19733
|
-
|
|
19734
|
-
|
|
19759
|
+
buildScoreEvent({
|
|
19760
|
+
traceId: this.#raw.traceId,
|
|
19761
|
+
spanId: this.id,
|
|
19762
|
+
correlationContext: buildCorrelationContext(this.#raw, this.#rootSpan, this.parent),
|
|
19735
19763
|
score,
|
|
19736
|
-
|
|
19764
|
+
inheritedMetadata: this.#raw.metadata
|
|
19737
19765
|
})
|
|
19738
19766
|
);
|
|
19739
19767
|
}
|
|
@@ -19743,12 +19771,12 @@ var RecordedSpanImpl = class {
|
|
|
19743
19771
|
return;
|
|
19744
19772
|
}
|
|
19745
19773
|
await this.#emitRecordedEvent(
|
|
19746
|
-
|
|
19747
|
-
|
|
19748
|
-
|
|
19749
|
-
|
|
19774
|
+
buildFeedbackEvent({
|
|
19775
|
+
traceId: this.#raw.traceId,
|
|
19776
|
+
spanId: this.id,
|
|
19777
|
+
correlationContext: buildCorrelationContext(this.#raw, this.#rootSpan, this.parent),
|
|
19750
19778
|
feedback,
|
|
19751
|
-
|
|
19779
|
+
inheritedMetadata: this.#raw.metadata
|
|
19752
19780
|
})
|
|
19753
19781
|
);
|
|
19754
19782
|
}
|
|
@@ -19781,10 +19809,11 @@ var RecordedTraceImpl = class {
|
|
|
19781
19809
|
return;
|
|
19782
19810
|
}
|
|
19783
19811
|
await this.#emitRecordedEvent(
|
|
19784
|
-
|
|
19785
|
-
|
|
19786
|
-
|
|
19787
|
-
score
|
|
19812
|
+
buildScoreEvent({
|
|
19813
|
+
traceId: this.#rootRecord.traceId,
|
|
19814
|
+
correlationContext: buildCorrelationContext(this.#rootRecord, this.#rootRecord),
|
|
19815
|
+
score,
|
|
19816
|
+
inheritedMetadata: this.#rootRecord.metadata
|
|
19788
19817
|
})
|
|
19789
19818
|
);
|
|
19790
19819
|
}
|
|
@@ -19794,10 +19823,11 @@ var RecordedTraceImpl = class {
|
|
|
19794
19823
|
return;
|
|
19795
19824
|
}
|
|
19796
19825
|
await this.#emitRecordedEvent(
|
|
19797
|
-
|
|
19798
|
-
|
|
19799
|
-
|
|
19800
|
-
feedback
|
|
19826
|
+
buildFeedbackEvent({
|
|
19827
|
+
traceId: this.#rootRecord.traceId,
|
|
19828
|
+
correlationContext: buildCorrelationContext(this.#rootRecord, this.#rootRecord),
|
|
19829
|
+
feedback,
|
|
19830
|
+
inheritedMetadata: this.#rootRecord.metadata
|
|
19801
19831
|
})
|
|
19802
19832
|
);
|
|
19803
19833
|
}
|
|
@@ -20219,6 +20249,22 @@ var Observability = class extends base.MastraBase {
|
|
|
20219
20249
|
});
|
|
20220
20250
|
}
|
|
20221
20251
|
async addScore(args) {
|
|
20252
|
+
const targetTraceId = args.traceId ?? args.correlationContext?.traceId;
|
|
20253
|
+
const targetSpanId = args.spanId ?? args.correlationContext?.spanId;
|
|
20254
|
+
if (args.correlationContext) {
|
|
20255
|
+
await this.#emitRecordedEvent(
|
|
20256
|
+
buildScoreEvent({
|
|
20257
|
+
...targetTraceId ? { traceId: targetTraceId } : {},
|
|
20258
|
+
...targetSpanId ? { spanId: targetSpanId } : {},
|
|
20259
|
+
correlationContext: args.correlationContext,
|
|
20260
|
+
score: args.score
|
|
20261
|
+
})
|
|
20262
|
+
);
|
|
20263
|
+
return;
|
|
20264
|
+
}
|
|
20265
|
+
if (!args.traceId) {
|
|
20266
|
+
return;
|
|
20267
|
+
}
|
|
20222
20268
|
const trace = await this.#getStoredTrace(args.traceId);
|
|
20223
20269
|
if (!trace) {
|
|
20224
20270
|
return;
|
|
@@ -20234,6 +20280,22 @@ var Observability = class extends base.MastraBase {
|
|
|
20234
20280
|
await this.#emitRecordedEvent(event);
|
|
20235
20281
|
}
|
|
20236
20282
|
async addFeedback(args) {
|
|
20283
|
+
const targetTraceId = args.traceId ?? args.correlationContext?.traceId;
|
|
20284
|
+
const targetSpanId = args.spanId ?? args.correlationContext?.spanId;
|
|
20285
|
+
if (args.correlationContext) {
|
|
20286
|
+
await this.#emitRecordedEvent(
|
|
20287
|
+
buildFeedbackEvent({
|
|
20288
|
+
...targetTraceId ? { traceId: targetTraceId } : {},
|
|
20289
|
+
...targetSpanId ? { spanId: targetSpanId } : {},
|
|
20290
|
+
correlationContext: args.correlationContext,
|
|
20291
|
+
feedback: args.feedback
|
|
20292
|
+
})
|
|
20293
|
+
);
|
|
20294
|
+
return;
|
|
20295
|
+
}
|
|
20296
|
+
if (!args.traceId) {
|
|
20297
|
+
return;
|
|
20298
|
+
}
|
|
20237
20299
|
const trace = await this.#getStoredTrace(args.traceId);
|
|
20238
20300
|
if (!trace) {
|
|
20239
20301
|
return;
|