Skip to content

ref!: modify Attributes type for Logs and Metrics#1205

Merged
giortzisg merged 3 commits intomasterfrom
ref/attributes-type
Feb 24, 2026
Merged

ref!: modify Attributes type for Logs and Metrics#1205
giortzisg merged 3 commits intomasterfrom
ref/attributes-type

Conversation

@giortzisg
Copy link
Contributor

Description

This PR modifies attribute storing to be a map[string]attribute.Value.

The main drive for the attribute storing change is to strongly type the attributes API. Previously a user could bypass the attribute.Builder and set an attribute on a log with (highly unlikely, but good to guard against):

log := sentry.Log{}
log.Attributes["key"] = sentry.Attribute{Value: "whatever"}

This change also eliminates preemptively boxing the attribute values and allows us to use the attribute.Builder for setting attributes with no allocations.

Changelog Entry Instructions

To add a custom changelog entry, uncomment the section above. Supports:

  • Single entry: just write text
  • Multiple entries: use bullet points
  • Nested bullets: indent 4+ spaces

For more details: custom changelog entries

Reminders

Changelog Entry

  • change type signature of attributes for Logs and Metrics.
    • users are not supposed to modify Attributes directly on the Log/Metric itself, but this is still is a breaking change on the type.

This change eliminates preemptively boxing the attribute values and allows us to use the attribute.Builder for setting attributes with no allocations. This change also has the benefit of enforcing strong attribute types rather than any.
@giortzisg giortzisg requested a review from Litarnus February 23, 2026 13:31
@giortzisg giortzisg self-assigned this Feb 23, 2026
@github-actions
Copy link

github-actions bot commented Feb 23, 2026

Semver Impact of This PR

🔴 Major (breaking changes)

📋 Changelog Preview

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


Breaking Changes 🛠

  • Add support for go 1.26 by giortzisg in #1193
    • bump minimum supported go version to 1.24
  • change type signature of attributes for Logs and Metrics. by giortzisg in #1205
    • users are not supposed to modify Attributes directly on the Log/Metric itself, but this is still is a breaking change on the type.
  • Send uint64 overflowing attributes as numbers. by giortzisg in #1198
    • The SDK was converting overflowing uint64 attributes to strings for slog and logrus integrations. To eliminate double types for these attributes, the SDK now sends the overflowing attribute as is, and lets the server handle the overflow appropriately.
    • It is expected that overflowing unsigned integers would now get dropped, instead of converted to strings.

New Features ✨

  • Add zap logging integration by giortzisg in #1184
  • Log specific message for RequestEntityTooLarge by giortzisg in #1185

Bug Fixes 🐛

  • Improve otel span map cleanup performance by giortzisg in #1200
  • Ensure correct signal delivery on multi-client setups by giortzisg in #1190

Internal Changes 🔧

Deps

  • Bump golang.org/x/crypto to 0.48.0 by giortzisg in #1196
  • Use go1.24.0 by giortzisg in #1195
  • Bump github.com/gofiber/fiber/v2 from 2.52.9 to 2.52.11 in /fiber by dependabot in #1191
  • Bump getsentry/craft from 2.19.0 to 2.20.1 by dependabot in #1187

Other

  • Add omitzero and remove custom serialization by giortzisg in #1197
  • Rename Telemetry Processor components by giortzisg in #1186

🤖 This preview updates automatically when you update the PR.

for _, v := range attrs {
t, ok := mapTypesToStr[v.Value.Type()]
if !ok || t == "" {
debuglog.Printf("invalid attribute type set: %v", t)

Choose a reason for hiding this comment

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

Should we keep the debug log if an invalid type is found?

@giortzisg giortzisg enabled auto-merge (squash) February 24, 2026 13:57
@giortzisg giortzisg merged commit 44caaae into master Feb 24, 2026
18 checks passed
@giortzisg giortzisg deleted the ref/attributes-type branch February 24, 2026 13:59
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.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

}

defaultAttrs := make(map[string]Attribute)
defaultAttrs := make(map[string]attribute.Value)
Copy link

Choose a reason for hiding this comment

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

Missing capacity hint for map initialization

Low Severity

The defaultAttrs map is initialized without a capacity hint, unlike the identical code in log.go line 78 which uses make(map[string]attribute.Value, len(defaults)). This inconsistency causes an unnecessary reallocation when attributes are added since the map size is known upfront.

Fix in Cursor Fix in Web

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.

2 participants