@mastra/otel-exporter 1.0.0-beta.1 → 1.0.0-beta.3

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,55 @@
1
1
  # @mastra/otel-exporter
2
2
 
3
+ ## 1.0.0-beta.3
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated OtelExporters, Bridge, and Arize packages to better implement GenAI v1.38.0 Otel Semantic Conventions. See: ([#10591](https://github.com/mastra-ai/mastra/pull/10591))
8
+ https://github.com/open-telemetry/semantic-conventions/blob/v1.38.0/docs/gen-ai/README.md
9
+
10
+ - feat(observability): Add tags support to OtelExporter, OtelBridge, and ArizeExporter ([#10843](https://github.com/mastra-ai/mastra/pull/10843))
11
+
12
+ This change adds support for the `tracingOptions.tags` feature to the OpenTelemetry-based exporters and bridge. Tags are now included as span attributes when present on root spans, following the same pattern as Braintrust and Langfuse exporters.
13
+
14
+ **Changes:**
15
+ - **OtelExporter**: Tags are now included as `mastra.tags` span attribute for root spans
16
+ - **OtelBridge**: Tags flow through the SpanConverter and are included in native OTEL spans as `mastra.tags`
17
+ - **ArizeExporter**: Tags are mapped to the native OpenInference `tag.tags` semantic convention
18
+
19
+ **Implementation Details:**
20
+ - Tags are only included on root spans (by design)
21
+ - Tags are stored as JSON-stringified arrays for maximum backend compatibility (many OTEL backends have limited native array support)
22
+ - Empty or undefined tag arrays are not included in span attributes
23
+
24
+ **Usage:**
25
+
26
+ ```typescript
27
+ const result = await agent.generate({
28
+ messages: [{ role: 'user', content: 'Hello' }],
29
+ tracingOptions: {
30
+ tags: ['production', 'experiment-v2'],
31
+ },
32
+ });
33
+ ```
34
+
35
+ Fixes #10771
36
+
37
+ - Updated dependencies [[`6c59a40`](https://github.com/mastra-ai/mastra/commit/6c59a40e0ad160467bd13d63a8a287028d75b02d), [`3076c67`](https://github.com/mastra-ai/mastra/commit/3076c6778b18988ae7d5c4c5c466366974b2d63f), [`85d7ee1`](https://github.com/mastra-ai/mastra/commit/85d7ee18ff4e14d625a8a30ec6656bb49804989b), [`c6c1092`](https://github.com/mastra-ai/mastra/commit/c6c1092f8fbf76109303f69e000e96fd1960c4ce), [`81dc110`](https://github.com/mastra-ai/mastra/commit/81dc11008d147cf5bdc8996ead1aa61dbdebb6fc), [`7aedb74`](https://github.com/mastra-ai/mastra/commit/7aedb74883adf66af38e270e4068fd42e7a37036), [`8f02d80`](https://github.com/mastra-ai/mastra/commit/8f02d800777397e4b45d7f1ad041988a8b0c6630), [`d7aad50`](https://github.com/mastra-ai/mastra/commit/d7aad501ce61646b76b4b511e558ac4eea9884d0), [`ce0a73a`](https://github.com/mastra-ai/mastra/commit/ce0a73abeaa75b10ca38f9e40a255a645d50ebfb), [`a02e542`](https://github.com/mastra-ai/mastra/commit/a02e542d23179bad250b044b17ff023caa61739f), [`a372c64`](https://github.com/mastra-ai/mastra/commit/a372c640ad1fd12e8f0613cebdc682fc156b4d95), [`8846867`](https://github.com/mastra-ai/mastra/commit/8846867ffa9a3746767618e314bebac08eb77d87), [`0bada2f`](https://github.com/mastra-ai/mastra/commit/0bada2f2c1234932cf30c1c47a719ffb64b801c5), [`42a42cf`](https://github.com/mastra-ai/mastra/commit/42a42cf3132b9786feecbb8c13c583dce5b0e198), [`cc60ff6`](https://github.com/mastra-ai/mastra/commit/cc60ff616541a3b0fb531a7e469bf9ae7bb90528), [`ae08bf0`](https://github.com/mastra-ai/mastra/commit/ae08bf0ebc6a4e4da992b711c4a389c32ba84cf4), [`21735a7`](https://github.com/mastra-ai/mastra/commit/21735a7ef306963554a69a89b44f06c3bcd85141), [`1d877b8`](https://github.com/mastra-ai/mastra/commit/1d877b8d7b536a251c1a7a18db7ddcf4f68d6f8b)]:
38
+ - @mastra/observability@1.0.0-beta.3
39
+ - @mastra/core@1.0.0-beta.7
40
+
41
+ ## 1.0.0-beta.2
42
+
43
+ ### Minor Changes
44
+
45
+ - Adds bidirectional integration with otel tracing via a new @mastra/otel-bridge package. ([#10482](https://github.com/mastra-ai/mastra/pull/10482))
46
+
47
+ ### Patch Changes
48
+
49
+ - Updated dependencies [[`ac0d2f4`](https://github.com/mastra-ai/mastra/commit/ac0d2f4ff8831f72c1c66c2be809706d17f65789), [`1a0d3fc`](https://github.com/mastra-ai/mastra/commit/1a0d3fc811482c9c376cdf79ee615c23bae9b2d6), [`85a628b`](https://github.com/mastra-ai/mastra/commit/85a628b1224a8f64cd82ea7f033774bf22df7a7e), [`c237233`](https://github.com/mastra-ai/mastra/commit/c23723399ccedf7f5744b3f40997b79246bfbe64), [`15f9e21`](https://github.com/mastra-ai/mastra/commit/15f9e216177201ea6e3f6d0bfb063fcc0953444f), [`ff94dea`](https://github.com/mastra-ai/mastra/commit/ff94dea935f4e34545c63bcb6c29804732698809), [`5b2ff46`](https://github.com/mastra-ai/mastra/commit/5b2ff4651df70c146523a7fca773f8eb0a2272f8), [`db41688`](https://github.com/mastra-ai/mastra/commit/db4168806d007417e2e60b4f68656dca4e5f40c9), [`103586c`](https://github.com/mastra-ai/mastra/commit/103586cb23ebcd2466c7f68a71674d37cc10e263), [`5ca599d`](https://github.com/mastra-ai/mastra/commit/5ca599d0bb59a1595f19f58473fcd67cc71cef58), [`bff1145`](https://github.com/mastra-ai/mastra/commit/bff114556b3cbadad9b2768488708f8ad0e91475), [`5c8ca24`](https://github.com/mastra-ai/mastra/commit/5c8ca247094e0cc2cdbd7137822fb47241f86e77), [`e191844`](https://github.com/mastra-ai/mastra/commit/e1918444ca3f80e82feef1dad506cd4ec6e2875f), [`22553f1`](https://github.com/mastra-ai/mastra/commit/22553f11c63ee5e966a9c034a349822249584691), [`7237163`](https://github.com/mastra-ai/mastra/commit/72371635dbf96a87df4b073cc48fc655afbdce3d), [`2500740`](https://github.com/mastra-ai/mastra/commit/2500740ea23da067d6e50ec71c625ab3ce275e64), [`873ecbb`](https://github.com/mastra-ai/mastra/commit/873ecbb517586aa17d2f1e99283755b3ebb2863f), [`4f9bbe5`](https://github.com/mastra-ai/mastra/commit/4f9bbe5968f42c86f4930b8193de3c3c17e5bd36), [`02e51fe`](https://github.com/mastra-ai/mastra/commit/02e51feddb3d4155cfbcc42624fd0d0970d032c0), [`8f3fa3a`](https://github.com/mastra-ai/mastra/commit/8f3fa3a652bb77da092f913ec51ae46e3a7e27dc), [`cd29ad2`](https://github.com/mastra-ai/mastra/commit/cd29ad23a255534e8191f249593849ed29160886), [`bdf4d8c`](https://github.com/mastra-ai/mastra/commit/bdf4d8cdc656d8a2c21d81834bfa3bfa70f56c16), [`854e3da`](https://github.com/mastra-ai/mastra/commit/854e3dad5daac17a91a20986399d3a51f54bf68b), [`ce18d38`](https://github.com/mastra-ai/mastra/commit/ce18d38678c65870350d123955014a8432075fd9), [`cccf9c8`](https://github.com/mastra-ai/mastra/commit/cccf9c8b2d2dfc1a5e63919395b83d78c89682a0), [`61a5705`](https://github.com/mastra-ai/mastra/commit/61a570551278b6743e64243b3ce7d73de915ca8a), [`db70a48`](https://github.com/mastra-ai/mastra/commit/db70a48aeeeeb8e5f92007e8ede52c364ce15287), [`f0fdc14`](https://github.com/mastra-ai/mastra/commit/f0fdc14ee233d619266b3d2bbdeea7d25cfc6d13), [`db18bc9`](https://github.com/mastra-ai/mastra/commit/db18bc9c3825e2c1a0ad9a183cc9935f6691bfa1), [`9b37b56`](https://github.com/mastra-ai/mastra/commit/9b37b565e1f2a76c24f728945cc740c2b09be9da), [`41a23c3`](https://github.com/mastra-ai/mastra/commit/41a23c32f9877d71810f37e24930515df2ff7a0f), [`5d171ad`](https://github.com/mastra-ai/mastra/commit/5d171ad9ef340387276b77c2bb3e83e83332d729), [`f03ae60`](https://github.com/mastra-ai/mastra/commit/f03ae60500fe350c9d828621006cdafe1975fdd8), [`d1e74a0`](https://github.com/mastra-ai/mastra/commit/d1e74a0a293866dece31022047f5dbab65a304d0), [`39e7869`](https://github.com/mastra-ai/mastra/commit/39e7869bc7d0ee391077ce291474d8a84eedccff), [`5761926`](https://github.com/mastra-ai/mastra/commit/57619260c4a2cdd598763abbacd90de594c6bc76), [`c900fdd`](https://github.com/mastra-ai/mastra/commit/c900fdd504c41348efdffb205cfe80d48c38fa33), [`604a79f`](https://github.com/mastra-ai/mastra/commit/604a79fecf276e26a54a3fe01bb94e65315d2e0e), [`887f0b4`](https://github.com/mastra-ai/mastra/commit/887f0b4746cdbd7cb7d6b17ac9f82aeb58037ea5), [`2562143`](https://github.com/mastra-ai/mastra/commit/256214336b4faa78646c9c1776612393790d8784), [`ef11a61`](https://github.com/mastra-ai/mastra/commit/ef11a61920fa0ed08a5b7ceedd192875af119749)]:
50
+ - @mastra/core@1.0.0-beta.6
51
+ - @mastra/observability@1.0.0-beta.2
52
+
3
53
  ## 1.0.0-beta.1
4
54
 
5
55
  ### Patch Changes
package/README.md CHANGED
@@ -359,7 +359,7 @@ Spans are named following OTEL conventions:
359
359
 
360
360
  - **LLM Operations**: `chat {model}` or `tool_selection {model}`
361
361
  - **Tool Execution**: `tool.execute {tool_name}`
362
- - **Agent Runs**: `agent.{agent_id}`
362
+ - **Agent Runs**: `invoke_agent {agent_name}`
363
363
  - **Workflow Runs**: `workflow.{workflow_id}`
364
364
 
365
365
  ### Attributes
@@ -369,7 +369,7 @@ The exporter maps Mastra's tracing data to OTEL-compliant attributes:
369
369
  #### Core Attributes
370
370
 
371
371
  - `gen_ai.operation.name` - Operation type (chat, tool.execute, agent.run, workflow.run)
372
- - `gen_ai.system` - AI provider (openai, anthropic, etc.)
372
+ - `gen_ai.provider.name` - AI provider (openai, anthropic, etc.)
373
373
  - `gen_ai.request.model` - Model identifier
374
374
 
375
375
  #### LLM-Specific Attributes
@@ -382,8 +382,12 @@ The exporter maps Mastra's tracing data to OTEL-compliant attributes:
382
382
  - `gen_ai.request.top_p` - Top-p sampling parameter
383
383
  - `gen_ai.request.top_k` - Top-k sampling parameter
384
384
  - `gen_ai.response.finish_reasons` - Reason for completion
385
+ - `gen_ai.response.model` - Actual model used in response (may differ from request)
386
+ - `gen_ai.response.id` - Unique response identifier
385
387
  - `gen_ai.prompt` - Input prompt (for Model spans)
386
388
  - `gen_ai.completion` - Model output (for Model spans)
389
+ - `server.address` - Server address for the model endpoint
390
+ - `server.port` - Server port for the model endpoint
387
391
 
388
392
  #### Tool Attributes
389
393
 
@@ -395,7 +399,10 @@ The exporter maps Mastra's tracing data to OTEL-compliant attributes:
395
399
 
396
400
  #### Agent & Workflow Attributes
397
401
 
398
- - `agent.id` - Agent identifier
402
+ - `gen_ai.agent.id` - Agent identifier
403
+ - `gen_ai.agent.name` - Human-readable agent name
404
+ - `gen_ai.conversation.id` - Conversation/thread/session identifier
405
+ - `agent.id` - Agent identifier (also included for compatibility)
399
406
  - `agent.max_steps` - Maximum agent steps
400
407
  - `workflow.id` - Workflow identifier
401
408
  - `workflow.status` - Workflow execution status
@@ -407,6 +414,43 @@ The exporter maps Mastra's tracing data to OTEL-compliant attributes:
407
414
  - `error.message` - Error description
408
415
  - `error.domain` - Error domain/category
409
416
 
417
+ ### Opt-In Content Attributes
418
+
419
+ For enhanced observability, you can enable additional content attributes that capture detailed message data. These attributes may contain sensitive information and should only be enabled with proper consent and security considerations.
420
+
421
+ To enable content attributes:
422
+
423
+ ```typescript
424
+ new OtelExporter({
425
+ provider: {
426
+ /* your provider config */
427
+ },
428
+ genAiConventions: {
429
+ includeContentAttributes: true, // Default: false
430
+ },
431
+ });
432
+ ```
433
+
434
+ When enabled, the following additional attributes are captured:
435
+
436
+ #### Model Content Attributes
437
+
438
+ - `gen_ai.input.messages` - Structured input messages in OpenTelemetry format
439
+ - `gen_ai.output.messages` - Structured output messages in OpenTelemetry format
440
+
441
+ These attributes convert Mastra's message format to the OpenTelemetry GenAI standard message schema, providing detailed conversation history and tool interactions.
442
+
443
+ #### Agent Content Attributes
444
+
445
+ - `gen_ai.system_instructions` - Agent system instructions/prompts
446
+
447
+ **Privacy Considerations:**
448
+
449
+ - These attributes may contain user data, prompts, and model responses
450
+ - Only enable in environments where data privacy and compliance requirements are met
451
+ - Consider using span processors to filter sensitive data before export
452
+ - Review your organization's data retention and privacy policies before enabling
453
+
410
454
  ## Troubleshooting
411
455
 
412
456
  ### Missing Dependency Error
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Utilities for converting Mastra messages to OpenTelemetry gen_ai message format
3
+ * Based on OpenTelemetry GenAI semantic conventions
4
+ * @see https://opentelemetry.io/docs/specs/semconv/registry/attributes/gen-ai/#gen-ai-input-messages
5
+ * @see https://opentelemetry.io/docs/specs/semconv/gen-ai/gen-ai-input-messages.json
6
+ */
7
+ /**
8
+ * Convert an Input/Output string from a MastraSpan into a jsonified string that adheres to
9
+ * OpenTelemetry gen_ai.input.messages and gen_ai.output.messages schema.
10
+ * If parsing fails at any step, the original inputOutputString is returned unmodified.
11
+ *
12
+ * This conversion is best effort; It assumes a consistent shape for mastra messages, and converts
13
+ * into the gen_ai input and output schemas as of October 20th, 2025.
14
+ *
15
+ * @see https://opentelemetry.io/docs/specs/semconv/registry/attributes/gen-ai/#gen-ai-input-messages
16
+ * @see https://opentelemetry.io/docs/specs/semconv/gen-ai/gen-ai-input-messages.json
17
+ * @see https://opentelemetry.io/docs/specs/semconv/registry/attributes/gen-ai/#gen-ai-output-messages
18
+ * @see https://opentelemetry.io/docs/specs/semconv/gen-ai/gen-ai-output-messages.json
19
+ *
20
+ * @param inputOutputString a jsonified string that contains messages adhering to what appears to be
21
+ * Mastra's message shape.
22
+ * @returns a jsonified string that contains messages adhering to the OpenTelemetry gen_ai.input.messages and gen_ai.output.messages schema.
23
+ * If parsing fails at any step, the original inputOutputString is returned unmodified.
24
+ */
25
+ export declare const convertMastraMessagesToGenAIMessages: (inputOutputString: string) => string;
26
+ //# sourceMappingURL=gen-ai-messages.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gen-ai-messages.d.ts","sourceRoot":"","sources":["../src/gen-ai-messages.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAwEH;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,oCAAoC,GAAI,mBAAmB,MAAM,KAAG,MAyEhF,CAAC"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Utilities for converting Mastra Spans to OTel Spans
3
+ * with Semantic conventions for generative AI systems
4
+ * @see https://github.com/open-telemetry/semantic-conventions/blob/v1.38.0/docs/gen-ai/README.md
5
+ * @see https://github.com/open-telemetry/semantic-conventions/blob/v1.38.0/docs/gen-ai/gen-ai-events.md
6
+ * @see https://github.com/open-telemetry/semantic-conventions/blob/v1.38.0/docs/gen-ai/gen-ai-spans.md
7
+ * @see https://github.com/open-telemetry/semantic-conventions/blob/v1.38.0/docs/gen-ai/gen-ai-agent-spans.md
8
+ * @see https://opentelemetry.io/docs/specs/semconv/gen-ai/non-normative/examples-llm-calls/
9
+ * @see https://opentelemetry.io/docs/specs/semconv/registry/attributes/gen-ai/
10
+ */
11
+ import type { AnyExportedSpan } from '@mastra/core/observability';
12
+ import type { Attributes } from '@opentelemetry/api';
13
+ /**
14
+ * Get an OTEL-compliant span name based on span type and attributes
15
+ */
16
+ export declare function getSpanName(span: AnyExportedSpan): string;
17
+ /**
18
+ * Gets OpenTelemetry attributes from Mastra Span
19
+ * Following OTEL Semantic Conventions for GenAI
20
+ */
21
+ export declare function getAttributes(span: AnyExportedSpan): Attributes;
22
+ //# sourceMappingURL=gen-ai-semantics.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gen-ai-semantics.d.ts","sourceRoot":"","sources":["../src/gen-ai-semantics.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,KAAK,EAEV,eAAe,EAKhB,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAsFrD;;GAEG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,eAAe,GAAG,MAAM,CAUzD;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,eAAe,GAAG,UAAU,CAwL/D"}