Skip to content

feat: Expose sentry conventions in UI #92370

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

Conversation

shruthilayaj
Copy link
Member

@shruthilayaj shruthilayaj commented May 27, 2025

Adds support to expose sentry conventions for deprecated attributes
behind a feature flag.

@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label May 27, 2025
Comment on lines 244 to 257
return list(
filter(
lambda x: not is_sentry_convention_replacement_attribute(
x["name"], trace_item_type
),
[
as_attribute_key(
attribute.name, serialized["attribute_type"], trace_item_type
)
for attribute in rpc_response.attributes
if attribute.name and can_expose_attribute(attribute.name, trace_item_type)
],
)
)
Copy link
Member Author

Choose a reason for hiding this comment

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

filter out all the sentry-conventions attributes

Comment on lines +457 to +459
SPAN_ATTRIBUTE_DEFINITIONS[replacement] = replace(
deprecated_attr, public_alias=replacement, internal_name=replacement
)
Copy link
Member Author

Choose a reason for hiding this comment

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

Doing a replace here so that I can preserve search_type if it's already defined and added a TODO to introduce units to the schema.

Comment on lines +461 to +473
SPAN_ATTRIBUTE_DEFINITIONS[key] = ResolvedAttribute(
public_alias=key,
internal_name=key,
search_type=attr_type,
replacement=replacement,
deprecation_status=status,
)

SPAN_ATTRIBUTE_DEFINITIONS[replacement] = ResolvedAttribute(
public_alias=replacement,
internal_name=replacement,
search_type=attr_type,
)
Copy link
Member Author

Choose a reason for hiding this comment

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

Adds the deprecated attributes to the definitions if they don't already exist so they get replaced with the new convention correctly.

@shruthilayaj shruthilayaj marked this pull request as ready for review May 28, 2025 16:47
@shruthilayaj shruthilayaj requested review from a team as code owners May 28, 2025 16:47
@shruthilayaj shruthilayaj requested a review from wmak May 28, 2025 16:49
Copy link

codecov bot commented May 28, 2025

Codecov Report

Attention: Patch coverage is 94.28571% with 6 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/sentry/search/eap/spans/attributes.py 80.64% 6 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #92370      +/-   ##
==========================================
+ Coverage   87.89%   87.94%   +0.05%     
==========================================
  Files       10226    10216      -10     
  Lines      586028   585322     -706     
  Branches    22763    22638     -125     
==========================================
- Hits       515112   514790     -322     
+ Misses      70487    70076     -411     
- Partials      429      456      +27     

Copy link
Member

@wmak wmak left a comment

Choose a reason for hiding this comment

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

Minor comments mostly, as discussed in slack:
the json is a short-term solution but long term will be replaced by a package 👍

Comment on lines +432 to +436
try:
with open(os.path.join(SENTRY_CONVENTIONS_DIRECTORY, "deprecated_attributes.json"), "rb") as f:
DEPRECATED_ATTRIBUTES = json.loads(f.read())["attributes"]
except Exception:
logger.exception("Failed to load deprecated attributes from 'deprecated_attributes.json'")
Copy link
Member

Choose a reason for hiding this comment

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

In addition to this check 🤔 would it help to have a test that would effectively make sure that the json is accessible and valid?

@@ -0,0 +1,938 @@
{
"_generated": "This file is generated. Do not modify it directly. See scripts/generate_deprecated_attributes_json.ts",
Copy link
Member

Choose a reason for hiding this comment

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

Is this file being added separately? Should we merge it in first before landing this change

Copy link
Member

Choose a reason for hiding this comment

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

Keeping previous comment to explain why; I think we should change the text here so its clearer that its from another Repo

https://github.com/getsentry/sentry-conventions/blob/main/scripts/generate_deprecated_attributes_json.ts


attribute_keys[attr_key["name"]] = attr_key

return list(attribute_keys.values())
Copy link
Member

Choose a reason for hiding this comment

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

would it be worth tagging the two lists & feature flag state?

@shruthilayaj shruthilayaj merged commit 5d33e62 into master May 29, 2025
60 checks passed
@shruthilayaj shruthilayaj deleted the shruthilayajaganathan/exp-271-expose-sentry-conventions-attributes-in-the-ui-allowed branch May 29, 2025 15:00
andrewshie-sentry pushed a commit that referenced this pull request Jun 2, 2025
Adds support to expose sentry conventions for deprecated attributes
behind a feature flag.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Scope: Backend Automatically applied to PRs that change backend components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants