Add device and OS attributes to metrics on mobile, as the native SDKs do

Open
#6,046 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
38/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
csharp

Research direction

Read the metrics spec linked in the issue and compare its default attribute guidance with the native SDK behavior described for sentry-java and sentry-cocoa. If the SDK and ingest teams decide .NET should match the native SDKs, inspect SentryOptions.DeviceLogAttributes and SentryMetric.Factory.cs, where SetDefaultAttributes is called. Done means the decision is reflected consistently in the metrics attributes and, if needed, the spec.

Written by the indexing model from the issue text.

Description

Feature Metrics State: Needs Discussion
Problem Statement

#6028 adds device and OS attributes (os.name, os.version, device.brand, device.model, device.family) to structured logs on Android, iOS and Mac Catalyst, as the logs spec asks of mobile SDKs. Metrics don't get them.

The native SDKs we wrap do add them to metrics:

  • sentry-java (8.66.0): DefaultAndroidEventProcessor.process(SentryMetricsEvent, Hint) sets the same five attributes it sets on logs.
  • sentry-cocoa (9.35.0): TelemetryScopeApplier adds the OS and device attributes to every telemetry item, metrics included.

So a metric emitted from .NET on Android or iOS carries fewer attributes than one emitted from the native SDK in the same app.

Why this needs a decision first

The metrics spec doesn't list device or OS attributes. It also says SDKs SHOULD minimize default attributes because of cardinality, and that new defaults SHOULD only be added after discussion with the SDK and ingest teams. The native SDKs go beyond that.

The question is whether .NET should match the native SDKs or follow the spec as written, and whether the spec should be updated.

Solution Brainstorm

If we match the native SDKs, the work is small. #6028 adds an internal SentryOptions.DeviceLogAttributes hook, filled by the Android and Cocoa integrations and applied in SentryLog.SetDefaultAttributes. Metrics would apply the same hook in SentryMetric.Factory.cs, where SetDefaultAttributes is already called. The hook would then want a name that isn't specific to logs.

Dominant language
C#
Stars
775
Forks
262
Avg merge
1d 16h
Merged PRs (30d)
118

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from getsentry/sentry-dotnet

All issues in getsentry/sentry-dotnet

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.