@mastra/observability 1.11.0 → 1.11.1-alpha.1
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 +46 -0
- package/dist/exporters/base.d.ts +1 -1
- package/dist/exporters/base.d.ts.map +1 -1
- package/dist/index.cjs +23 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +23 -8
- package/dist/index.js.map +1 -1
- package/dist/model-tracing.d.ts.map +1 -1
- package/dist/spans/base.d.ts.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,51 @@
|
|
|
1
1
|
# @mastra/observability
|
|
2
2
|
|
|
3
|
+
## 1.11.1-alpha.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Reduced startup noise: CloudExporter missing-token message is now logged at debug level instead of warn, since being disabled is the expected state for local development ([#16070](https://github.com/mastra-ai/mastra/pull/16070))
|
|
8
|
+
|
|
9
|
+
- Updated dependencies [[`c05c9a1`](https://github.com/mastra-ai/mastra/commit/c05c9a13230988cef6d438a62f37760f31927bc7), [`e24aacb`](https://github.com/mastra-ai/mastra/commit/e24aacba07bd66f5d95b636dc24016fca26b52cf), [`c721164`](https://github.com/mastra-ai/mastra/commit/c7211643f7ac861f83b19a3757cc921487fc9d75), [`1b55954`](https://github.com/mastra-ai/mastra/commit/1b559541c1e08a10e49d01ffc51a634dfc37a286), [`5adc55e`](https://github.com/mastra-ai/mastra/commit/5adc55e63407be8ee977914957d68bcc2a075ceb), [`70017d7`](https://github.com/mastra-ai/mastra/commit/70017d72ab741b5d7040e2a15c251a317782e39e), [`e4942bc`](https://github.com/mastra-ai/mastra/commit/e4942bc7fdc903572f7d84f26d5e15f9d39c763d)]:
|
|
10
|
+
- @mastra/core@1.32.0-alpha.1
|
|
11
|
+
|
|
12
|
+
## 1.11.1-alpha.0
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- Fixed model step traces to show the final prompt sent to the model, including memory-injected system messages. ([#16029](https://github.com/mastra-ai/mastra/pull/16029))
|
|
17
|
+
|
|
18
|
+
- Added a new `DatadogBridge` integration for Mastra tracing so Datadog can keep auto-instrumented HTTP, database, and framework spans nested under the agent, workflow, model, and tool spans that triggered them. ([#15716](https://github.com/mastra-ai/mastra/pull/15716))
|
|
19
|
+
|
|
20
|
+
```typescript
|
|
21
|
+
import tracer from 'dd-trace';
|
|
22
|
+
|
|
23
|
+
tracer.init({
|
|
24
|
+
service: process.env.DD_SERVICE || 'my-mastra-app',
|
|
25
|
+
env: process.env.DD_ENV || 'production',
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
import { Mastra } from '@mastra/core';
|
|
29
|
+
import { Observability } from '@mastra/observability';
|
|
30
|
+
import { DatadogBridge } from '@mastra/datadog';
|
|
31
|
+
|
|
32
|
+
const mastra = new Mastra({
|
|
33
|
+
observability: new Observability({
|
|
34
|
+
configs: {
|
|
35
|
+
default: {
|
|
36
|
+
serviceName: 'my-mastra-app',
|
|
37
|
+
bridge: new DatadogBridge({
|
|
38
|
+
mlApp: process.env.DD_LLMOBS_ML_APP!,
|
|
39
|
+
}),
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
}),
|
|
43
|
+
});
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
- Updated dependencies [[`6dcd65f`](https://github.com/mastra-ai/mastra/commit/6dcd65f2a34069e6dc43ba35f1d11119b9b40bef), [`1c2dda8`](https://github.com/mastra-ai/mastra/commit/1c2dda805fbfccc0abf55d4cb20cc34402dc3f0c)]:
|
|
47
|
+
- @mastra/core@1.31.1-alpha.0
|
|
48
|
+
|
|
3
49
|
## 1.11.0
|
|
4
50
|
|
|
5
51
|
### Minor Changes
|
package/dist/exporters/base.d.ts
CHANGED
|
@@ -100,7 +100,7 @@ export declare abstract class BaseExporter implements ObservabilityExporter {
|
|
|
100
100
|
*
|
|
101
101
|
* @param reason - Reason why the exporter is disabled
|
|
102
102
|
*/
|
|
103
|
-
protected setDisabled(reason: string): void;
|
|
103
|
+
protected setDisabled(reason: string, level?: 'warn' | 'debug'): void;
|
|
104
104
|
/**
|
|
105
105
|
* Apply the customSpanFormatter if configured.
|
|
106
106
|
* This is called automatically by exportTracingEvent before _exportTracingEvent.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../src/exporters/base.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAiB,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,KAAK,EACV,YAAY,EACZ,qBAAqB,EACrB,mBAAmB,EACnB,mBAAmB,EACpB,MAAM,4BAA4B,CAAC;AAEpC;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,sCAAsC;IACtC,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB,mFAAmF;IACnF,QAAQ,CAAC,EAAE,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;IAC1D;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACH,mBAAmB,CAAC,EAAE,mBAAmB,CAAC;CAC3C;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,8BAAsB,YAAa,YAAW,qBAAqB;;IACjE,wDAAwD;IACxD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB,6BAA6B;IAC7B,SAAS,CAAC,MAAM,EAAE,aAAa,CAAC;IAEhC,oDAAoD;IACpD,SAAS,CAAC,QAAQ,CAAC,UAAU,EAAE,kBAAkB,CAAC;IAKlD,uCAAuC;IACvC,IAAI,UAAU,IAAI,OAAO,CAExB;IAED;;OAEG;gBACS,MAAM,GAAE,kBAAuB;IAQ3C;;OAEG;IACH,WAAW,CAAC,MAAM,EAAE,aAAa,GAAG,I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EAAE,KAAK,GAAE,MAAM,GAAG,OAAgB,GAAG,IAAI;IAK7E;;;;;;;;;OASG;cACa,kBAAkB,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC;IAoB9E;;;;;;;;;OASG;IACH,cAAc,CAAC,KAAK,EAAE,YAAY,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAIzD;;;;;;OAMG;IACG,kBAAkB,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IAQ5D;;;;OAIG;IACH,SAAS,CAAC,QAAQ,CAAC,mBAAmB,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IAE1E;;OAEG;IACH,IAAI,CAAC,CAAC,QAAQ,EAAE,mBAAmB,GAAG,IAAI;IAE1C;;OAEG;IACH,eAAe,CAAC,CAAC,KAAK,EAAE;QACtB,OAAO,EAAE,MAAM,CAAC;QAChB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,UAAU,EAAE,MAAM,CAAC;QACnB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;KAChC,GAAG,OAAO,CAAC,IAAI,CAAC;IAEjB;;;;;;;;OAQG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAI5B;;;;OAIG;IACG,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;CAGhC"}
|
package/dist/index.cjs
CHANGED
|
@@ -13993,9 +13993,9 @@ var BaseExporter = class {
|
|
|
13993
13993
|
*
|
|
13994
13994
|
* @param reason - Reason why the exporter is disabled
|
|
13995
13995
|
*/
|
|
13996
|
-
setDisabled(reason) {
|
|
13996
|
+
setDisabled(reason, level = "warn") {
|
|
13997
13997
|
this.#disabled = true;
|
|
13998
|
-
this.logger
|
|
13998
|
+
this.logger[level](`${this.name} disabled: ${reason}`);
|
|
13999
13999
|
}
|
|
14000
14000
|
/**
|
|
14001
14001
|
* Apply the customSpanFormatter if configured.
|
|
@@ -15179,7 +15179,7 @@ var CloudExporter = class extends BaseExporter {
|
|
|
15179
15179
|
const rawProjectId = config2.projectId ?? process.env.MASTRA_PROJECT_ID;
|
|
15180
15180
|
const projectId = rawProjectId && VALID_PROJECT_ID.test(rawProjectId) ? rawProjectId : void 0;
|
|
15181
15181
|
if (!accessToken) {
|
|
15182
|
-
this.setDisabled("MASTRA_CLOUD_ACCESS_TOKEN environment variable not set.");
|
|
15182
|
+
this.setDisabled("MASTRA_CLOUD_ACCESS_TOKEN environment variable not set.", "debug");
|
|
15183
15183
|
}
|
|
15184
15184
|
const tracesEndpointOverride = config2.tracesEndpoint ?? process.env.MASTRA_CLOUD_TRACES_ENDPOINT;
|
|
15185
15185
|
let baseEndpoint;
|
|
@@ -18741,7 +18741,11 @@ function summarizeRequestBody(body) {
|
|
|
18741
18741
|
}
|
|
18742
18742
|
return Object.keys(summary).length > 0 ? summary : "[request body]";
|
|
18743
18743
|
}
|
|
18744
|
-
function extractStepInput(
|
|
18744
|
+
function extractStepInput(payload) {
|
|
18745
|
+
if (Array.isArray(payload?.inputMessages)) {
|
|
18746
|
+
return normalizeMessages(payload.inputMessages);
|
|
18747
|
+
}
|
|
18748
|
+
const request = payload?.request;
|
|
18745
18749
|
if (!request) return void 0;
|
|
18746
18750
|
const { body } = request;
|
|
18747
18751
|
if (body == null) return request;
|
|
@@ -18761,6 +18765,7 @@ var ModelSpanTracker = class {
|
|
|
18761
18765
|
#stepIndex = 0;
|
|
18762
18766
|
#chunkSequence = 0;
|
|
18763
18767
|
#completionStartTime;
|
|
18768
|
+
#currentStepInputIsFinal = false;
|
|
18764
18769
|
/** When true, step-finish chunks don't auto-close the step span (for durable execution) */
|
|
18765
18770
|
#deferStepClose = false;
|
|
18766
18771
|
/** Stored step-finish payload when defer mode is enabled */
|
|
@@ -18854,6 +18859,7 @@ var ModelSpanTracker = class {
|
|
|
18854
18859
|
if (this.#currentStepSpan) {
|
|
18855
18860
|
return;
|
|
18856
18861
|
}
|
|
18862
|
+
const input = extractStepInput(payload);
|
|
18857
18863
|
this.#currentStepSpan = this.#modelSpan?.createChildSpan({
|
|
18858
18864
|
name: `step: ${this.#stepIndex}`,
|
|
18859
18865
|
type: observability.SpanType.MODEL_STEP,
|
|
@@ -18862,8 +18868,9 @@ var ModelSpanTracker = class {
|
|
|
18862
18868
|
...payload?.messageId ? { messageId: payload.messageId } : {},
|
|
18863
18869
|
...payload?.warnings?.length ? { warnings: payload.warnings } : {}
|
|
18864
18870
|
},
|
|
18865
|
-
input
|
|
18871
|
+
input
|
|
18866
18872
|
});
|
|
18873
|
+
this.#currentStepInputIsFinal = Array.isArray(payload?.inputMessages);
|
|
18867
18874
|
this.#chunkSequence = 0;
|
|
18868
18875
|
}
|
|
18869
18876
|
/**
|
|
@@ -18874,13 +18881,18 @@ var ModelSpanTracker = class {
|
|
|
18874
18881
|
if (!this.#currentStepSpan || !payload) {
|
|
18875
18882
|
return;
|
|
18876
18883
|
}
|
|
18884
|
+
const hasFinalInput = Array.isArray(payload.inputMessages);
|
|
18885
|
+
const input = hasFinalInput || !this.#currentStepInputIsFinal ? extractStepInput(payload) : void 0;
|
|
18877
18886
|
this.#currentStepSpan.update({
|
|
18878
|
-
input:
|
|
18887
|
+
...input !== void 0 ? { input } : {},
|
|
18879
18888
|
attributes: {
|
|
18880
18889
|
...payload.messageId ? { messageId: payload.messageId } : {},
|
|
18881
18890
|
...payload.warnings?.length ? { warnings: payload.warnings } : {}
|
|
18882
18891
|
}
|
|
18883
18892
|
});
|
|
18893
|
+
if (hasFinalInput) {
|
|
18894
|
+
this.#currentStepInputIsFinal = true;
|
|
18895
|
+
}
|
|
18884
18896
|
}
|
|
18885
18897
|
/**
|
|
18886
18898
|
* End the current Model execution step with token usage, finish reason, output, and metadata
|
|
@@ -18912,6 +18924,7 @@ var ModelSpanTracker = class {
|
|
|
18912
18924
|
}
|
|
18913
18925
|
});
|
|
18914
18926
|
this.#currentStepSpan = void 0;
|
|
18927
|
+
this.#currentStepInputIsFinal = false;
|
|
18915
18928
|
this.#stepIndex++;
|
|
18916
18929
|
}
|
|
18917
18930
|
/**
|
|
@@ -19487,7 +19500,8 @@ var BaseSpan = class {
|
|
|
19487
19500
|
async executeInContext(fn) {
|
|
19488
19501
|
const bridge = this.observabilityInstance.getBridge();
|
|
19489
19502
|
if (bridge?.executeInContext) {
|
|
19490
|
-
|
|
19503
|
+
const bridgeContextSpan = this.isInternal ? this.getParentSpan(false) : this;
|
|
19504
|
+
return bridge.executeInContext(bridgeContextSpan?.id ?? this.id, fn);
|
|
19491
19505
|
}
|
|
19492
19506
|
return fn();
|
|
19493
19507
|
}
|
|
@@ -19498,7 +19512,8 @@ var BaseSpan = class {
|
|
|
19498
19512
|
executeInContextSync(fn) {
|
|
19499
19513
|
const bridge = this.observabilityInstance.getBridge();
|
|
19500
19514
|
if (bridge?.executeInContextSync) {
|
|
19501
|
-
|
|
19515
|
+
const bridgeContextSpan = this.isInternal ? this.getParentSpan(false) : this;
|
|
19516
|
+
return bridge.executeInContextSync(bridgeContextSpan?.id ?? this.id, fn);
|
|
19502
19517
|
}
|
|
19503
19518
|
return fn();
|
|
19504
19519
|
}
|