Skip to content

feat(preprod): Store metrics artifact type as string in EAP (EME-874)#112905

Open
cameroncooke wants to merge 3 commits intomasterfrom
cameroncooke/feat/preprod-artifact-type-string-column
Open

feat(preprod): Store metrics artifact type as string in EAP (EME-874)#112905
cameroncooke wants to merge 3 commits intomasterfrom
cameroncooke/feat/preprod-artifact-type-string-column

Conversation

@cameroncooke
Copy link
Copy Markdown
Contributor

@cameroncooke cameroncooke commented Apr 14, 2026

Stores metrics_artifact_type as a human-readable string label (e.g. main_artifact, watch_artifact) instead of an integer enum value when writing PREPROD size metrics to EAP. This replaces the previous approach of trying to map integer enums to display names at the frontend/query layer, which was invasive and couldn't leverage the existing string value autocomplete pipeline.

The new public search field artifact_type resolves to the internal metrics_artifact_type string attribute, making it eligible for Explore's existing value autocomplete. Deprecated integer-backed fields (metrics_artifact_type, tags[metrics_artifact_type,number], tags[artifact_type,number]) are hidden from the UI.

Also extracts METRICS_ARTIFACT_TYPES as a canonical shared constant on the frontend, so the settings UI composes its all_artifacts sentinel on top rather than baking it into the base list.

The tradeoff is no backfill for existing EAP data — only newly written rows will have string values. This is acceptable since we're early going with PREPROD metrics.

Screenshots

Screenshot 2026-04-14 at 09 20 55

Known risks

  • Name collision: The public alias artifact_type now points to the internal metrics_artifact_type (string), but there is also a raw artifact_type integer attribute in EAP representing the build artifact kind (XCARCHIVE/AAB/APK). The old integer artifact_type is hidden from the UI but still written to EAP.
  • Breaking change for existing queries: Any saved queries or dashboard widgets using the old metrics_artifact_type integer field or the old artifact_type integer field will no longer resolve through the search definitions. Given we are early going with PREPROD, the impact should be minimal and user-recoverable.
  • Historical data: Old EAP rows retain their integer values. The new string-backed artifact_type field will only match rows written after this change.

Fixes EME-874

Write metrics_artifact_type as a human-readable string label instead of
an integer enum value when producing PREPROD size metric EAP trace items.
This enables string-based value autocomplete in Explore search without
needing enum-to-name mapping at the display layer.

- Add to_choice_label() helper on MetricsArtifactType enum
- Update EAP write path to emit string labels
- Repoint PREPROD search field as public artifact_type (string)
- Add artifact_type to frontend string defaults with predefined values
- Hide deprecated integer fields from Explore UI
- Extract METRICS_ARTIFACT_TYPES as canonical shared constant

Refs EME-874
Co-Authored-By: Claude Sonnet 4 <noreply@anthropic.com>
@linear-code
Copy link
Copy Markdown

linear-code bot commented Apr 14, 2026

@github-actions github-actions bot added Scope: Frontend Automatically applied to PRs that change frontend components Scope: Backend Automatically applied to PRs that change backend components labels Apr 14, 2026
@github-actions
Copy link
Copy Markdown
Contributor

🚨 Warning: This pull request contains Frontend and Backend changes!

It's discouraged to make changes to Sentry's Frontend and Backend in a single pull request. The Frontend and Backend are not atomically deployed. If the changes are interdependent of each other, they must be separated into two pull requests and be made forward or backwards compatible, such that the Backend or Frontend can be safely deployed independently.

Have questions? Please ask in the #discuss-dev-infra channel.

@cameroncooke cameroncooke changed the title feat(preprod): Store metrics artifact type as string in EAP feat(preprod): Store metrics artifact type as string in EAP (EME-874) Apr 14, 2026
@cameroncooke cameroncooke marked this pull request as ready for review April 14, 2026 09:49
@cameroncooke cameroncooke requested review from a team as code owners April 14, 2026 09:49
@github-actions
Copy link
Copy Markdown
Contributor

Backend Test Failures

Failures on a249895 in this run:

tests/snuba/preprod/eap/test_preprod_eap_integration.py::PreprodEAPIntegrationTest::test_write_and_read_size_metric_round_triplog
[gw0] linux -- Python 3.13.1 /home/runner/work/sentry/sentry/.venv/bin/python3
tests/snuba/preprod/eap/test_preprod_eap_integration.py:100: in test_write_and_read_size_metric_round_trip
    assert (
E   AssertionError: assert '' == 'main_artifact'
E     
E     - main_artifact

…rror handling

- Update read.py attribute definition to search_type="string" matching the
  write path change (fixes integration test round-trip failure)
- Extract _metrics_artifact_type_label helper with ValueError handling for
  invalid database values (addresses Warden feedback)
Copy link
Copy Markdown
Contributor

@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 is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit d692518. Configure here.

…ersion

Handles the case where an enum member exists but is missing from
as_choices(), preventing a crash in the EAP write path.
@sentry
Copy link
Copy Markdown
Contributor

sentry bot commented Apr 14, 2026

Sentry Snapshot Testing

Name Added Removed Modified Renamed Unchanged Status
sentry-frontend
sentry-frontend
0 0 0 0 204 ✅ Unchanged

"size_metric_id": size_metric.id,
"sub_item_type": "size_metric",
"metrics_artifact_type": size_metric.metrics_artifact_type,
"metrics_artifact_type": _metrics_artifact_type_label(size_metric.metrics_artifact_type),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Just want to confirm this is safe to do and that you've tested changing a column type with existing data.

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 Scope: Frontend Automatically applied to PRs that change frontend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants