Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat: Support array types for logs and metrics attributes #5314

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
alexander-alderman-webb wants to merge 1 commit into master
base: master
Choose a base branch
Loading
from webb/support-array-units

Conversation

@alexander-alderman-webb
Copy link
Contributor

@alexander-alderman-webb alexander-alderman-webb commented Jan 14, 2026

Description

Allow array attribute types as Relay now supports them.

Note: the monolith may still need to make changes to query and expose the attributes.

Issues

Reminders

Copy link
Contributor

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 ✨

  • feat(ai): add parse_data_uri function to parse a data URI by constantinius in #5311
  • feat(asyncio): Add on-demand way to enable AsyncioIntegration by sentrivana in #5288
  • feat: Support array types for logs and metrics attributes by alexander-alderman-webb in #5314

Bug Fixes 🐛

  • fix(ai): redact message parts content of type blob by constantinius in #5243
  • fix(clickhouse): Guard against module shadowing by alexander-alderman-webb in #5250
  • fix(gql): Revert signature change of patched gql.Client.execute by alexander-alderman-webb in #5289
  • fix(grpc): Derive interception state from channel fields by alexander-alderman-webb in #5302
  • fix(litellm): Guard against module shadowing by alexander-alderman-webb in #5249
  • fix(pure-eval): Guard against module shadowing by alexander-alderman-webb in #5252
  • fix(ray): Guard against module shadowing by alexander-alderman-webb in #5254
  • fix(threading): Handle channels shadowing by sentrivana in #5299
  • fix(typer): Guard against module shadowing by alexander-alderman-webb in #5253
  • fix: Send client reports for span recorder overflow by sentrivana in #5310

Documentation 📚

  • docs(metrics): Remove experimental notice by alexander-alderman-webb in #5304
  • docs: Update Python versions banner in README by sentrivana in #5287

Internal Changes 🔧

Release

  • ci(release): Bump Craft version to fix issues by BYK in #5305
  • ci(release): Switch from action-prepare-release to Craft by BYK in #5290

Other

  • chore(gen_ai): add auto-enablement for google genai by shellmayr in #5295
  • ci: Update tox and handle generic classifiers by sentrivana in #5306

🤖 This preview updates automatically when you update the PR.

Comment on lines 217 to 223
Hint = Dict[str, Any]

AttributeValue = (
str | bool | float | int
# TODO: relay support coming soon for
# | list[str] | list[bool] | list[float] | list[int]
str | bool | float | int | list[str] | list[bool] | list[float] | list[int]
)
Attributes = dict[str, AttributeValue]

Copy link

@sentry sentry bot Jan 14, 2026

Choose a reason for hiding this comment

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

Bug: The format_attribute and serialize_attribute functions don't handle list types, causing array attributes to be incorrectly serialized as strings instead of the intended array types.
Severity: CRITICAL

Suggested Fix

Update format_attribute and serialize_attribute in sentry_sdk/utils.py to correctly handle list types. In format_attribute, ensure lists are passed through without modification. In serialize_attribute, add logic to detect lists of primitives (str, bool, int, float) and serialize them to the corresponding array types (string[], boolean[], integer[], double[]). Add unit tests to cover these new array attribute types.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.
Location: sentry_sdk/_types.py#L217-L223
Potential issue: The PR introduced support for array types (`list[str]`, `list[int]`,
etc.) in the `AttributeValue` type definition. However, the functions responsible for
processing these attributes, `format_attribute` and `serialize_attribute`, were not
updated. When an array is passed as an attribute, `format_attribute` converts it to its
string representation (e.g., `"['a', 'b']"`) via `safe_repr`. Subsequently,
`serialize_attribute` treats this string as a simple string value, sending `{"type":
"string"}` to the backend instead of the expected array type like `{"type":
"string[]"}`. This leads to silent data corruption for metrics and logs using array
attributes.

Did we get this right? 👍 / 👎 to inform future reviews.

Copy link
Contributor Author

@alexander-alderman-webb alexander-alderman-webb Jan 14, 2026

Choose a reason for hiding this comment

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

thanks, will address tomorrow

Comment on lines 217 to 223
Hint = Dict[str, Any]

AttributeValue = (
str | bool | float | int
# TODO: relay support coming soon for
# | list[str] | list[bool] | list[float] | list[int]
str | bool | float | int | list[str] | list[bool] | list[float] | list[int]
)
Attributes = dict[str, AttributeValue]

Copy link

@sentry sentry bot Jan 14, 2026

Choose a reason for hiding this comment

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

Bug: The functions format_attribute and serialize_attribute do not handle list types, causing array attributes to be incorrectly serialized as strings via safe_repr.
Severity: CRITICAL

Suggested Fix

Update format_attribute and serialize_attribute to properly handle list types. In serialize_attribute, add logic to detect if the value is a list, determine the type of its elements (e.g., int, str), and serialize it to the corresponding array type (e.g., {"value": [1, 2], "type": "integer[]"}). Ensure format_attribute preserves the list type instead of converting it to a string.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.
Location: sentry_sdk/_types.py#L217-L223
Potential issue: The pull request updates the `AttributeValue` type to support lists
(e.g., `list[int]`), but the implementation in `format_attribute` and
`serialize_attribute` was not updated to handle them. When an array is passed as an
attribute, `format_attribute` converts it to its string representation using
`safe_repr`. Consequently, `serialize_attribute` treats this value as a string and
serializes it with `{"type": "string"}`. This silently breaks the new array attribute
feature, as the backend receives a string instead of an array, preventing correct
processing and querying.

Did we get this right? 👍 / 👎 to inform future reviews.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@sentry sentry[bot] sentry[bot] left review comments

@cursor cursor[bot] cursor[bot] left review comments

@sentrivana sentrivana sentrivana approved these changes

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /