Skip to content

Enrich attributes of Spans created from PerformanceMeasure events #16237

Description

@allista

Problem Statement

Sentry automatically creates Spans from PerformanceEvents, which is great 👍

But manually created measure events contain the analog of Span.attributes named PerformanceMeasure.detail, which are not propagated to traces.

Here's how the native measure event looks in dev-tools:

Image

And here's the Span created from it, lacking vital data:

Image

My request is

...to enrich Span.attributes with the detail data 🙏

Thank you for consideration! 😊

Solution Brainstorm

The caveat is, of course, that the PerformanceMeasure.detail is not type-restricted and can be anything whatsoever:

interface PerformanceMeasureOptions {
    detail?: any;
    duration?: DOMHighResTimeStamp;
    end?: string | DOMHighResTimeStamp;
    start?: string | DOMHighResTimeStamp;
}

Naturally, I would expect Sentry to support the same data types as in Span.attributes itself. Anything extra can be gracefully dropped, or serialized somehow, if configured explicitly:

export function _convertToSpanAttributes(data: unknown): SpanAttributes {
  // type checks, attribute traversals, array maps, etc...
}

export function _extractAttributesFromEntry(entry: PerformanceEntry): SpanAttributes {
  if(isPerformanceMeasure(entry)) {
    return _convertToSpanAttributes(entry.detail);
  }
  // Here we can support more entry types
  return {};
}

export function _addMeasureSpans(...
  ...

  // The PerformanceMeasure may contain arbitrary metadata in "detail" attribute.
  // We try to add as much as possible from "detail" to attributes
  const attributesFromEntry = _extractAttributesFromEntry(entry);

  const attributes: SpanAttributes = {
    ...attributesFromEntry,
    [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.resource.browser.metrics',
  };

Product Area

Unknown

Activity

  1. getsantry commented on May 8, 2025

    @getsantry

    Assigning to @getsentry/support for routing ⏲️

  2. moved this to Waiting for: Support in GitHub Issues with 👀 3on May 8, 2025
  3. AbhiPrasad commented on May 8, 2025

    @AbhiPrasad
    Contributor

    transferring this to the JS SDK repo!

  4. transferred this issue fromgetsentry/sentryon May 8, 2025
  5. moved this from Waiting for: Support to Waiting for: Product Owner in GitHub Issues with 👀 3on May 8, 2025
  6. self-assigned this
    on May 8, 2025
  7. AbhiPrasad commented on May 8, 2025

    @AbhiPrasad
    Contributor

    I think this is a reasonable ask - opened a PR: #16240

  8. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 3on May 8, 2025
  9. github-actions commented on May 19, 2025

    @github-actions
    Contributor

    A PR closing this issue has just been released 🚀

    This issue was referenced by PR #16240, which was included in the 9.20.0 release.

  10. AbhiPrasad commented on May 20, 2025

    @AbhiPrasad
    Contributor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions