Uh oh!
There was an error while loading. Please reload this page.
feat(core): Add scope attribute APIs - #18165
Conversation
There was a problem hiding this comment.
In contrast to logs and metrics attribute definitions and helper functions, this one already handles array attributes as well as attributes with units. My thinking is, we introduce this here then unify logs, metrics (+ spans eventually) to use the types and APIs here. While we'll have to change the used types for logs and metrics, I don't think this is breaking as theoretically logs and metrics support unknown for attribute values.
3209923 to
c94bcd6Comparesize-limit report 📦
|
node-overhead report 🧳Note: This is a synthetic benchmark with a minimal express app and does not necessarily reflect the real-world performance impact in an application.
|
Scope::setAttribute(s) APIsUh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
a3e204d to
205752cCompareLms24
commented
Nov 19, 2025
Converting to draft because we learned yesterday that Relay doesn't yet support array attributes. So either we wait for support in Relay or we strip out the Array-related code. Units seem to get passed through but are not yet shown in the UI. |
205752c to
fbbd768CompareLms24
commented
Nov 20, 2025
So for now, we decided to just ship this, despite Relay still filtering out array values. Units are accepted but not shown in the UI. Which is fine. We're just future-proofing at this point. |
Uh oh!
There was an error while loading. Please reload this page.
…ype (#18201) Uses a conditional type to infer whether an attribute object has the type of an official attribute by checking if it has a `value` or a `unit`: ```ts export type ValidatedAttributes<T> = { [K in keyof T]: T[K] extends { value: any } | { unit: any } ? ValidAttributeObject : unknown; }; ``` That way, TS can show an error when people attempt to use the attribute type while still allowing non-official types. <img width="673" height="250" alt="image" src="https://github.com/user-attachments/assets/f635f46d-6c3f-49cb-b31f-a02a6ebf91d3" /> --- I also added a small helper type to generate the very long attribute type object, so it can generate a type like this: ```ts /* | { value: string; type: 'string' } | { value: number; type: 'integer' } | { value: number; type: 'double' } */ ```
fbbd768 to
04d75b1CompareUh oh!
There was an error while loading. Please reload this page.
This PR adds
scope.setAttribute,scope.setAttributesandscope.removeAttributemethods, as specified in our develop docs.This intial PR only enables setting the attributes (including attributes with units) as well as the usual scope data operations (clone(), update(), clear(), getSpanData()). These attributes are not yet applied to any of the telemetry we eventually want them to apply to. I'll take care of this in a follow-up PR.
closes#18140
ref https://linear.app/getsentry/project/implement-global-attributes-api-javascript-02c3c74184fc/issues