Skip to content

Enrich attributes of Spans created from PerformanceMeasure events #16237

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
allista opened this issue May 8, 2025 · 3 comments · May be fixed by #16240
Open

Enrich attributes of Spans created from PerformanceMeasure events #16237

allista opened this issue May 8, 2025 · 3 comments · May be fixed by #16240
Assignees

Comments

@allista
Copy link

allista commented May 8, 2025

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

@getsantry
Copy link

getsantry bot commented May 8, 2025

Assigning to @getsentry/support for routing ⏲️

@getsantry getsantry bot moved this to Waiting for: Support in GitHub Issues with 👀 3 May 8, 2025
@AbhiPrasad
Copy link
Member

transferring this to the JS SDK repo!

@AbhiPrasad AbhiPrasad transferred this issue from getsentry/sentry May 8, 2025
@getsantry getsantry bot moved this from Waiting for: Support to Waiting for: Product Owner in GitHub Issues with 👀 3 May 8, 2025
@AbhiPrasad AbhiPrasad self-assigned this May 8, 2025
@AbhiPrasad
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

Successfully merging a pull request may close this issue.

2 participants