@mastra/otel-exporter 1.3.0-alpha.0 → 1.3.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,26 @@
1
1
  # @mastra/otel-exporter
2
2
 
3
+ ## 1.3.1-alpha.0
4
+
5
+ ### Patch Changes
6
+
7
+ - Fixed RAG embedding spans so OpenTelemetry exports include embedding model, provider, usage, span name, and client span kind metadata. ([#17917](https://github.com/mastra-ai/mastra/pull/17917))
8
+
9
+ - Updated dependencies [[`5bd72d2`](https://github.com/mastra-ai/mastra/commit/5bd72d255f45b5ea8ab342643bd463814a980a24), [`1cc9ee1`](https://github.com/mastra-ai/mastra/commit/1cc9ee1ba51db53020a735626d33017a60b4b5b3), [`417baae`](https://github.com/mastra-ai/mastra/commit/417baae40b995db5819c845036947f0c27dc1c00), [`74955f9`](https://github.com/mastra-ai/mastra/commit/74955f9120cde8b1d8ce4399232b4033236be858), [`30ebaf0`](https://github.com/mastra-ai/mastra/commit/30ebaf07bed5f4d30f2f257836c15d1bf7e40aae), [`5704634`](https://github.com/mastra-ai/mastra/commit/5704634b22133167dea337a942a34f57aaa3fa14), [`417baae`](https://github.com/mastra-ai/mastra/commit/417baae40b995db5819c845036947f0c27dc1c00), [`74955f9`](https://github.com/mastra-ai/mastra/commit/74955f9120cde8b1d8ce4399232b4033236be858), [`74955f9`](https://github.com/mastra-ai/mastra/commit/74955f9120cde8b1d8ce4399232b4033236be858), [`c0eda2b`](https://github.com/mastra-ai/mastra/commit/c0eda2bcd91a228427314b12c91d8b147f3a739f), [`c0eda2b`](https://github.com/mastra-ai/mastra/commit/c0eda2bcd91a228427314b12c91d8b147f3a739f), [`b13925b`](https://github.com/mastra-ai/mastra/commit/b13925bfa91aa8700f56fa54a9ce707ee7e4ba62), [`bf94ec6`](https://github.com/mastra-ai/mastra/commit/bf94ec68192d9f16e46ef7e5ac36370aeeddf35d), [`a29f371`](https://github.com/mastra-ai/mastra/commit/a29f371aef629ac8562661524a497127e93b5131), [`74955f9`](https://github.com/mastra-ai/mastra/commit/74955f9120cde8b1d8ce4399232b4033236be858), [`073f910`](https://github.com/mastra-ai/mastra/commit/073f910481e7d94b95ba3830f96531774ae95d33), [`ebbe1d3`](https://github.com/mastra-ai/mastra/commit/ebbe1d31a965a3adb0e728758f326b8122b4b55f), [`1f97ce5`](https://github.com/mastra-ai/mastra/commit/1f97ce5695463bebb4eaacf501da6fb403e20885), [`74955f9`](https://github.com/mastra-ai/mastra/commit/74955f9120cde8b1d8ce4399232b4033236be858), [`64f58c0`](https://github.com/mastra-ai/mastra/commit/64f58c04e78b40137497d47f781e897e416f22a5), [`74955f9`](https://github.com/mastra-ai/mastra/commit/74955f9120cde8b1d8ce4399232b4033236be858), [`ebbe1d3`](https://github.com/mastra-ai/mastra/commit/ebbe1d31a965a3adb0e728758f326b8122b4b55f), [`417baae`](https://github.com/mastra-ai/mastra/commit/417baae40b995db5819c845036947f0c27dc1c00), [`8e25a78`](https://github.com/mastra-ai/mastra/commit/8e25a78e0597575f0b0729bae8c5e190c84869b5), [`417baae`](https://github.com/mastra-ai/mastra/commit/417baae40b995db5819c845036947f0c27dc1c00), [`a5b22d3`](https://github.com/mastra-ai/mastra/commit/a5b22d314d62a68d801886a8d3d0eb6c089473db), [`417baae`](https://github.com/mastra-ai/mastra/commit/417baae40b995db5819c845036947f0c27dc1c00), [`74955f9`](https://github.com/mastra-ai/mastra/commit/74955f9120cde8b1d8ce4399232b4033236be858), [`74955f9`](https://github.com/mastra-ai/mastra/commit/74955f9120cde8b1d8ce4399232b4033236be858)]:
10
+ - @mastra/core@1.46.0-alpha.0
11
+
12
+ ## 1.3.0
13
+
14
+ ### Minor Changes
15
+
16
+ - Random bump ([#18178](https://github.com/mastra-ai/mastra/pull/18178))
17
+
18
+ ### Patch Changes
19
+
20
+ - Updated dependencies [[`7c0d868`](https://github.com/mastra-ai/mastra/commit/7c0d868d97d0fdbc04c14d0166dbf44d4c5a4a62), [`d9d2273`](https://github.com/mastra-ai/mastra/commit/d9d2273c702690c9a26eab2aebea879701d4355a), [`b04369d`](https://github.com/mastra-ai/mastra/commit/b04369d6b167c698ef103981171a8bf92808e756), [`8f3c262`](https://github.com/mastra-ai/mastra/commit/8f3c262587b335588a02d96b17fd6aca34c885b3)]:
21
+ - @mastra/core@1.45.0
22
+ - @mastra/observability@1.15.0
23
+
3
24
  ## 1.3.0-alpha.0
4
25
 
5
26
  ### Minor Changes
@@ -1 +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,EAIf,UAAU,EACX,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAgBL,8BAA8B,EAC9B,+BAA+B,EAC/B,yCAAyC,EACzC,6CAA6C,EAY9C,MAAM,gDAAgD,CAAC;AAGxD;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B,CAAC,8BAA8B,CAAC,CAAC,EAAE,MAAM,CAAC;IAC1C,CAAC,+BAA+B,CAAC,CAAC,EAAE,MAAM,CAAC;IAC3C,CAAC,yCAAyC,CAAC,CAAC,EAAE,MAAM,CAAC;IACrD,CAAC,6CAA6C,CAAC,CAAC,EAAE,MAAM,CAAC;IACzD,+BAA+B,CAAC,EAAE,MAAM,CAAC;IACzC,iCAAiC,CAAC,EAAE,MAAM,CAAC;IAC3C,kCAAkC,CAAC,EAAE,MAAM,CAAC;CAC7C;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,CAAC,EAAE,UAAU,GAAG,gBAAgB,CAqCvE;AAuCD;;GAEG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,eAAe,GAAG,MAAM,CAUzD;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,eAAe,GAAG,UAAU,CAyL/D"}
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,EAKf,UAAU,EACX,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAgBL,8BAA8B,EAC9B,+BAA+B,EAC/B,yCAAyC,EACzC,6CAA6C,EAY9C,MAAM,gDAAgD,CAAC;AAGxD;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B,CAAC,8BAA8B,CAAC,CAAC,EAAE,MAAM,CAAC;IAC1C,CAAC,+BAA+B,CAAC,CAAC,EAAE,MAAM,CAAC;IAC3C,CAAC,yCAAyC,CAAC,CAAC,EAAE,MAAM,CAAC;IACrD,CAAC,6CAA6C,CAAC,CAAC,EAAE,MAAM,CAAC;IACzD,+BAA+B,CAAC,EAAE,MAAM,CAAC;IACzC,iCAAiC,CAAC,EAAE,MAAM,CAAC;IAC3C,kCAAkC,CAAC,EAAE,MAAM,CAAC;CAC7C;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,CAAC,EAAE,UAAU,GAAG,gBAAgB,CAqCvE;AA4DD;;GAEG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,eAAe,GAAG,MAAM,CAUzD;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,eAAe,GAAG,UAAU,CAgM/D"}
package/dist/index.cjs CHANGED
@@ -408,10 +408,21 @@ function formatUsageMetrics(usage) {
408
408
  }
409
409
  return metrics;
410
410
  }
411
+ function addModelRequestAttributes(attributes, attrs) {
412
+ if (attrs.model) {
413
+ attributes[incubating.ATTR_GEN_AI_REQUEST_MODEL] = attrs.model;
414
+ }
415
+ if (attrs.provider) {
416
+ attributes[incubating.ATTR_GEN_AI_PROVIDER_NAME] = normalizeProvider(attrs.provider);
417
+ }
418
+ Object.assign(attributes, formatUsageMetrics(attrs.usage));
419
+ }
411
420
  function getOperationName(span) {
412
421
  switch (span.type) {
413
422
  case observability.SpanType.MODEL_GENERATION:
414
423
  return "chat";
424
+ case observability.SpanType.RAG_EMBEDDING:
425
+ return "embeddings";
415
426
  case observability.SpanType.TOOL_CALL:
416
427
  case observability.SpanType.MCP_TOOL_CALL:
417
428
  return "execute_tool";
@@ -432,6 +443,10 @@ function getSpanIdentifier(span) {
432
443
  const attrs = span.attributes;
433
444
  return attrs?.model;
434
445
  }
446
+ case observability.SpanType.RAG_EMBEDDING: {
447
+ const attrs = span.attributes;
448
+ return attrs?.model;
449
+ }
435
450
  default:
436
451
  return span.entityName ?? span.entityId;
437
452
  }
@@ -471,19 +486,13 @@ function getAttributes(span) {
471
486
  }
472
487
  if (span.type === observability.SpanType.MODEL_GENERATION && span.attributes) {
473
488
  const modelAttrs = span.attributes;
474
- if (modelAttrs.model) {
475
- attributes[incubating.ATTR_GEN_AI_REQUEST_MODEL] = modelAttrs.model;
476
- }
477
- if (modelAttrs.provider) {
478
- attributes[incubating.ATTR_GEN_AI_PROVIDER_NAME] = normalizeProvider(modelAttrs.provider);
479
- }
489
+ addModelRequestAttributes(attributes, modelAttrs);
480
490
  if (span.entityId) {
481
491
  attributes[incubating.ATTR_GEN_AI_AGENT_ID] = span.entityId;
482
492
  }
483
493
  if (span.entityName) {
484
494
  attributes[incubating.ATTR_GEN_AI_AGENT_NAME] = span.entityName;
485
495
  }
486
- Object.assign(attributes, formatUsageMetrics(modelAttrs.usage));
487
496
  if (modelAttrs.parameters) {
488
497
  if (modelAttrs.parameters.temperature !== void 0) {
489
498
  attributes[incubating.ATTR_GEN_AI_REQUEST_TEMPERATURE] = modelAttrs.parameters.temperature;
@@ -529,6 +538,20 @@ function getAttributes(span) {
529
538
  attributes[incubating.ATTR_SERVER_PORT] = modelAttrs.serverPort;
530
539
  }
531
540
  }
541
+ if (span.type === observability.SpanType.RAG_EMBEDDING && span.attributes) {
542
+ const embeddingAttrs = span.attributes;
543
+ addModelRequestAttributes(attributes, embeddingAttrs);
544
+ if (embeddingAttrs.mode) {
545
+ attributes[`mastra.${spanType}.mode`] = embeddingAttrs.mode;
546
+ }
547
+ if (embeddingAttrs.dimensions !== void 0) {
548
+ attributes["gen_ai.embeddings.dimension.count"] = embeddingAttrs.dimensions;
549
+ attributes[`mastra.${spanType}.dimensions`] = embeddingAttrs.dimensions;
550
+ }
551
+ if (embeddingAttrs.inputCount !== void 0) {
552
+ attributes[`mastra.${spanType}.input_count`] = embeddingAttrs.inputCount;
553
+ }
554
+ }
532
555
  if ((span.type === observability.SpanType.TOOL_CALL || span.type === observability.SpanType.MCP_TOOL_CALL) && span.attributes) {
533
556
  attributes[incubating.ATTR_GEN_AI_TOOL_NAME] = span.entityName ?? span.entityId;
534
557
  if (span.type === observability.SpanType.MCP_TOOL_CALL) {
@@ -730,6 +753,7 @@ async function getPackageVersion(pkgName) {
730
753
  function getSpanKind(type) {
731
754
  switch (type) {
732
755
  case observability.SpanType.MODEL_GENERATION:
756
+ case observability.SpanType.RAG_EMBEDDING:
733
757
  case observability.SpanType.MCP_TOOL_CALL:
734
758
  return api.SpanKind.CLIENT;
735
759
  default: