Skip to content

feat(attributes): Add device context attributes#300

Merged
buenaflor merged 8 commits intomainfrom
buenaflor/feat/add-device-context-attributes
Mar 23, 2026
Merged

feat(attributes): Add device context attributes#300
buenaflor merged 8 commits intomainfrom
buenaflor/feat/add-device-context-attributes

Conversation

@buenaflor
Copy link
Contributor

@buenaflor buenaflor commented Mar 23, 2026

Description

Add device context attributes based on the Sentry Contexts Interface:

  • device.free_memory — Free system memory in bytes
  • device.memory_size — Total system memory available in bytes
  • device.simulator — Whether the device is a simulator or an actual device
  • device.model_id — An internal hardware revision to identify the device exactly
  • device.class — The classification of the device (e.g. low, medium, high)
  • device.processor_count — Logical CPU core count

PR Checklist

  • I have run yarn test and verified that the tests pass.
  • I have run yarn generate to generate and format code and docs.

If an attribute was added:

  • The attribute is in a namespace (e.g. nextjs.function_id, not function_id)
  • I have used the correct value for pii (i.e. maybe or true. Use false only for values that should never be scrubbed such as IDs)

If an attribute was deprecated:

Add device context attributes for memory, simulator, model ID, class,
and processor count (deprecated in favor of device.cpu.logical_core_count).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@github-actions
Copy link

github-actions bot commented Mar 23, 2026

Semver Impact of This PR

🟡 Minor (new features)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


New Features ✨

Attributes

  • Add device context attributes by buenaflor in #300
  • Add app context attributes for mobile by buenaflor in #296
  • Add device memory and core count attributes by Lms24 in #281
  • Add ui.element.* attributes by Lms24 in #284
  • Add remaining TTFB, FCP and FP web vital attributes by Lms24 in #235
  • Add LCP web vital meta attributes by Lms24 in #233
  • Add CLS web vital source attribute by Lms24 in #234
  • Add core web web vital value attributes by Lms24 in #229
  • Add allow_any_value field to attribute schema by vgrozdanic in #272

Other

  • (http) Add http.server.request.time_in_queue attribute by dingsdax in #267
  • (resource) Add resource.deployment.environment by mjq in #266
  • Add sentry.timestamp.sequence attribute to the spec by logaretm in #262
  • Add changelog tracking to attribute definitions by ericapisani in #270

Bug Fixes 🐛

  • (attributes) Remove allow_any_value boolean attribute and allow any as type by vgrozdanic in #273
  • (gen_ai) Input and output token description by obostjancic in #261
  • (sentry) Deprecate sentry.trace.parent_span_id by mjq in #287
  • Don't run changelog generation on yarn generate by Lms24 in #277
  • Avoid changelog generation recursion by Lms24 in #274

Documentation 📚

  • (sentry) Add deprecated sentry.source by s1gr1d in #288
  • Redirect from old /generated pages to new routes by Lms24 in #291
  • Remove extra yarn run format instruction by mjq in #289
  • Update README with up-to-date links by ericapisani in #258

Internal Changes 🔧

Deps

  • Bump h3 from 1.15.5 to 1.15.9 by dependabot in #299
  • Bump devalue from 5.6.3 to 5.6.4 by dependabot in #286
  • Bump dompurify from 3.3.1 to 3.3.2 by dependabot in #278
  • Bump svgo from 3.3.2 to 3.3.3 by dependabot in #275
  • Bump svelte from 5.51.5 to 5.53.5 by dependabot in #271
  • Bump rollup from 4.40.1 to 4.59.0 by dependabot in #269
  • Bump svelte from 5.48.1 to 5.51.5 by dependabot in #260

Deps Dev

  • Bump tar from 7.5.10 to 7.5.11 by dependabot in #285
  • Bump tar from 7.5.8 to 7.5.10 by dependabot in #276
  • Bump tar from 7.5.7 to 7.5.8 by dependabot in #259

Other

  • (ai) Deprecate rest of ai.* attributes by constantinius in #264
  • (attributes) Ensure each attribute json has a changelog entry by Lms24 in #282
  • (docs) Upgrade to Astro 6 by Lms24 in #283
  • (gen_ai) Deprecate gen_ai.tool.input, gen_ai.tool.message, gen_ai.tool.output by constantinius in #265
  • (publish) Bump next entries in changelog when releasing by Lms24 in #290
  • (repo) Populate changelog property when running yarn create:attribute by Lms24 in #280
  • Wrong link to CONTRIBUTING.md in PR template by sentrivana in #298

🤖 This preview updates automatically when you update the PR.

@buenaflor buenaflor marked this pull request as ready for review March 23, 2026 10:18
Copilot AI review requested due to automatic review settings March 23, 2026 10:18
@buenaflor buenaflor requested review from a team, Lms24, cleptric, lcian, mjq and nsdeschenes as code owners March 23, 2026 10:18
@buenaflor
Copy link
Contributor Author

@Lms24 I saw you added device.cpu.logical_core_count, in mobile we use device.processor_count which is the exact same attribute.

we can keep this as stable and have device.processor_count be deprecated. wdyt?

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds additional device context attribute definitions (and corresponding generated bindings) aligned with Sentry’s Contexts “device” interface, including a deprecation/alias relationship for device.processor_count.

Changes:

  • Added new device attributes: device.free_memory, device.memory_size, device.simulator, device.model_id, device.class.
  • Deprecated device.processor_count and introduced aliasing with device.cpu.logical_core_count.
  • Regenerated Python + JavaScript attribute constants/metadata/types to include the new attributes and aliases.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
shared/deprecated_attributes.json Registers device.processor_count as deprecated and points to the replacement attribute.
python/src/sentry_conventions/attributes.py Adds new device attribute constants + metadata and updates alias metadata for logical core count.
javascript/sentry-conventions/src/attributes.ts Adds new device attribute exports/types/metadata and updates alias metadata for logical core count.
model/attributes/device/device__class.json New attribute definition for device.class.
model/attributes/device/device__free_memory.json New attribute definition for device.free_memory.
model/attributes/device/device__memory_size.json New attribute definition for device.memory_size.
model/attributes/device/device__model_id.json New attribute definition for device.model_id.
model/attributes/device/device__simulator.json New attribute definition for device.simulator.
model/attributes/device/device__processor_count.json New (deprecated) attribute definition for device.processor_count.
model/attributes/device/device__cpu__logical_core_count.json Updates aliases to include device.processor_count.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

buenaflor and others added 3 commits March 23, 2026 11:24
Add missing cross-references so device.cpu.logical_core_count,
hardwareConcurrency, and device.processor_count all list each other
as aliases. Also regenerate generated files.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix prepared a fix for the issue found in the latest run.

  • ✅ Fixed: PII marking inconsistent with similar existing memory attribute
    • Changed pii from 'false' to 'maybe' for device.memory_size and device.free_memory to be consistent with device.memory.estimated_capacity and other device metrics.

Create PR

Or push these changes by commenting:

@cursor push 9b7d4cd503
Preview (9b7d4cd503)
diff --git a/model/attributes/device/device__free_memory.json b/model/attributes/device/device__free_memory.json
--- a/model/attributes/device/device__free_memory.json
+++ b/model/attributes/device/device__free_memory.json
@@ -3,7 +3,7 @@
   "brief": "Free system memory in bytes.",
   "type": "integer",
   "pii": {
-    "key": "false"
+    "key": "maybe"
   },
   "is_in_otel": false,
   "example": 2147483648,

diff --git a/model/attributes/device/device__memory_size.json b/model/attributes/device/device__memory_size.json
--- a/model/attributes/device/device__memory_size.json
+++ b/model/attributes/device/device__memory_size.json
@@ -3,7 +3,7 @@
   "brief": "Total system memory available in bytes.",
   "type": "integer",
   "pii": {
-    "key": "false"
+    "key": "maybe"
   },
   "is_in_otel": false,
   "example": 17179869184,

This Bugbot Autofix run was free. To enable autofix for future PRs, go to the Cursor dashboard.

Aligns with existing device.memory.estimated_capacity which also uses
pii: maybe, since precise memory values could be used for fingerprinting.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
Member

@Lms24 Lms24 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Lms24 I saw you added device.cpu.logical_core_count, in mobile we use device.processor_count which is the exact same attribute.
we can keep this as stable and have device.processor_count be deprecated. wdyt?

Sounds good to me! If both represent the logical and not physical count we should unify them. That being said, if anything in the product depends on device.processor_count, we could also do it the other way around. If not, I'd slightly prefer device.cpu.logical_core_count as it's more explicit.

@buenaflor
Copy link
Contributor Author

If both represent the logical and not physical count we should unify them

yup they do

anything in the product depends on device.processor_count

ah good point, I'll double check

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@buenaflor
Copy link
Contributor Author

@Lms24 it looks like processor_count is used a couple times

  • Event detail UI: Displayed as "Processor Count" in the device context panel on event pages
  • Android device classification: Parsed from event tags to determine if a device is "high-end" (feeds into an analytics event)

so we may have to deprecate it the other way around

@Lms24
Copy link
Member

Lms24 commented Mar 23, 2026

Thanks for checking! Then agreed, let's turn it around

@Lms24
Copy link
Member

Lms24 commented Mar 23, 2026

@buenaflor actually, you can just remove device.cpu.logical_core_count. I only added this to JS for span-first, so this isn't shipped anywhere. Then we can spare ourselves the deprecation. But we need to keep hardwareConcurrency deprecated.

Remove device.cpu.logical_core_count since it was never shipped.
Make device.processor_count the canonical attribute and update
hardwareConcurrency deprecation to point to device.processor_count.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
Member

@Lms24 Lms24 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks!

Set prs to [300] for all device context attribute changelog entries
that were missing PR references.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@buenaflor buenaflor merged commit e60e887 into main Mar 23, 2026
12 checks passed
@buenaflor buenaflor deleted the buenaflor/feat/add-device-context-attributes branch March 23, 2026 14:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants