@mastra/observability 1.23.1-alpha.0 → 1.23.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/dist/index.cjs CHANGED
@@ -3762,6 +3762,11 @@ var BaseSpan = class BaseSpan {
3762
3762
  this.correlationContext = void 0;
3763
3763
  }
3764
3764
  }
3765
+ /** Read at export time, not from the cached correlation context, so a service name set on update or end wins over the config. */
3766
+ resolveServiceName() {
3767
+ const value = this.metadata?.serviceName;
3768
+ return typeof value === "string" ? value : this.observabilityInstance.getConfig().serviceName;
3769
+ }
3765
3770
  /**
3766
3771
  * Build and cache the canonical correlation context for this live span.
3767
3772
  *
@@ -3826,7 +3831,7 @@ var BaseSpan = class BaseSpan {
3826
3831
  requestId: getMetadataString("requestId"),
3827
3832
  environment: getMetadataString("environment") ?? this.observabilityInstance.getMastraEnvironment?.(),
3828
3833
  source: getMetadataString("source"),
3829
- serviceName: getMetadataString("serviceName") ?? this.observabilityInstance.getConfig().serviceName,
3834
+ serviceName: this.resolveServiceName(),
3830
3835
  experimentId: getMetadataString("experimentId")
3831
3836
  };
3832
3837
  return this.correlationContext;
@@ -3838,6 +3843,7 @@ var BaseSpan = class BaseSpan {
3838
3843
  const nestedUnderParent = this.traceState?.nestedUnderParent ?? false;
3839
3844
  const links = validLinks(this.links);
3840
3845
  const correlation = this.getCorrelationContext();
3846
+ const serviceName = this.resolveServiceName();
3841
3847
  const timeToFirstTokenMs = this.attributes?.timeToFirstTokenMs;
3842
3848
  return {
3843
3849
  id: this.id,
@@ -3862,6 +3868,7 @@ var BaseSpan = class BaseSpan {
3862
3868
  isRootSpan: this.isRootSpan,
3863
3869
  ...this.isInternal ? { isInternal: true } : {},
3864
3870
  ...correlation.entityVersionId ? { entityVersionId: correlation.entityVersionId } : {},
3871
+ ...serviceName ? { serviceName } : {},
3865
3872
  ...definedLineage(correlation),
3866
3873
  parentSpanId: this.getParentSpanId(includeInternalSpans),
3867
3874
  externalParentSpanId: this.getExportedExternalParentSpanId(includeInternalSpans),