@mastra/observability 1.11.0-alpha.0 → 1.11.1-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 CHANGED
@@ -1,5 +1,53 @@
1
1
  # @mastra/observability
2
2
 
3
+ ## 1.11.1-alpha.0
4
+
5
+ ### Patch Changes
6
+
7
+ - 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))
8
+
9
+ - 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))
10
+
11
+ ```typescript
12
+ import tracer from 'dd-trace';
13
+
14
+ tracer.init({
15
+ service: process.env.DD_SERVICE || 'my-mastra-app',
16
+ env: process.env.DD_ENV || 'production',
17
+ });
18
+
19
+ import { Mastra } from '@mastra/core';
20
+ import { Observability } from '@mastra/observability';
21
+ import { DatadogBridge } from '@mastra/datadog';
22
+
23
+ const mastra = new Mastra({
24
+ observability: new Observability({
25
+ configs: {
26
+ default: {
27
+ serviceName: 'my-mastra-app',
28
+ bridge: new DatadogBridge({
29
+ mlApp: process.env.DD_LLMOBS_ML_APP!,
30
+ }),
31
+ },
32
+ },
33
+ }),
34
+ });
35
+ ```
36
+
37
+ - Updated dependencies [[`6dcd65f`](https://github.com/mastra-ai/mastra/commit/6dcd65f2a34069e6dc43ba35f1d11119b9b40bef), [`1c2dda8`](https://github.com/mastra-ai/mastra/commit/1c2dda805fbfccc0abf55d4cb20cc34402dc3f0c)]:
38
+ - @mastra/core@1.31.1-alpha.0
39
+
40
+ ## 1.11.0
41
+
42
+ ### Minor Changes
43
+
44
+ - Auto-attach the Mastra-level `environment` to all observability signals. ([#15956](https://github.com/mastra-ai/mastra/pull/15956))
45
+
46
+ ### Patch Changes
47
+
48
+ - Updated dependencies [[`1723e09`](https://github.com/mastra-ai/mastra/commit/1723e099829892419ddbfe49287acfeac2522724), [`629f9e9`](https://github.com/mastra-ai/mastra/commit/629f9e9a7e56aa8f129515a3923c5813298790c7), [`25168fb`](https://github.com/mastra-ai/mastra/commit/25168fb9c1de9db7f8171df4f58ceb842c53aa29), [`ab34b5a`](https://github.com/mastra-ai/mastra/commit/ab34b5a2191b8e4353df1dbf7b9155e7d6628d79), [`5fb6c2a`](https://github.com/mastra-ai/mastra/commit/5fb6c2a95c1843cc231704b91354311fc1f34a71), [`2b0f355`](https://github.com/mastra-ai/mastra/commit/2b0f3553be3e9e5524da539a66e5cf82668440a4), [`394f0cf`](https://github.com/mastra-ai/mastra/commit/394f0cfc31e6b4d801219fdef2e9cc69e5bc8682), [`b2deb29`](https://github.com/mastra-ai/mastra/commit/b2deb29412b300c868655b5840463614fbb7962d), [`66644be`](https://github.com/mastra-ai/mastra/commit/66644beac1aa560f0e417956ff007c89341dc382), [`e109607`](https://github.com/mastra-ai/mastra/commit/e10960749251e34d46b480a20648c490fd30381b), [`310b953`](https://github.com/mastra-ai/mastra/commit/310b95345f302dcd5ba3ed862bdc96f059d44122), [`3d7f709`](https://github.com/mastra-ai/mastra/commit/3d7f709b615e588050bb6283c4ee5cfe2978cbde), [`48a42f1`](https://github.com/mastra-ai/mastra/commit/48a42f114a4006a95e0b7a1b5ad1a24815a175c2), [`8091c7c`](https://github.com/mastra-ai/mastra/commit/8091c7c944d15e13fef6d61b6cfd903f158d4006), [`2c83efc`](https://github.com/mastra-ai/mastra/commit/2c83efc4482b3efe50830e3b8b4ba9a8d219edff), [`43f0e1d`](https://github.com/mastra-ai/mastra/commit/43f0e1d5d5a74ba6fc746f2ad89ebe0c64777a7d), [`da0b9e2`](https://github.com/mastra-ai/mastra/commit/da0b9e2ba7ecc560213b426d6c097fe63946086e), [`282a10c`](https://github.com/mastra-ai/mastra/commit/282a10c9446e9922afe80e10e3770481c8ac8a28), [`04151c7`](https://github.com/mastra-ai/mastra/commit/04151c7dcea934b4fe9076708a23fac161195414), [`8091c7c`](https://github.com/mastra-ai/mastra/commit/8091c7c944d15e13fef6d61b6cfd903f158d4006)]:
49
+ - @mastra/core@1.31.0
50
+
3
51
  ## 1.11.0-alpha.0
4
52
 
5
53
  ### Minor Changes
package/dist/index.cjs CHANGED
@@ -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(request) {
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: extractStepInput(payload?.request)
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: extractStepInput(payload.request),
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
- return bridge.executeInContext(this.id, fn);
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
- return bridge.executeInContextSync(this.id, fn);
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
  }