Skip to content
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

feat(metrics): Ignore transaction metrics allowlist [INGEST-1628] #1484

Merged
merged 28 commits into from
Sep 27, 2022

Conversation

jjbayer
Copy link
Member

@jjbayer jjbayer commented Sep 20, 2022

With custom measurements limited by the measurements config in event normalization (see #1483), we do not need the special allowlist for transaction metrics anymore.

Do not merge until getsentry/sentry#39001 has been deployed.

Note that after merging this PR, Sentry will still be sending the old config format to support old Relay instances. We will need a bump of transactionMetrics.VERSION to finally clean up that part.

#skip-changelog

@jjbayer jjbayer self-assigned this Sep 20, 2022
assert_eq!(metric.tags["platform"], "javascript");
assert!(!metric.tags.contains_key("bogus"));
}
insta::assert_debug_snapshot!(metrics, @r###"
Copy link
Member Author

Choose a reason for hiding this comment

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

The test diff is large because a few tests used the metrics allowlist to filter down metrics returned. In the process, I decided to replace ad-hoc assert statements with insta::assert_debug_snapshot! where possible.

Copy link
Contributor

Choose a reason for hiding this comment

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

The test diff is large because a few tests used the metrics allowlist to filter down metrics returned.

Definitely out of the scope of this PR, but tests should not interfere with other tests.

Copy link
Contributor

Choose a reason for hiding this comment

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

I like using snapshots (vs ad-hoc asserts) a lot. However, making this change in this PR makes focusing on the relevant aspects harder, vs having another PR for the refactor. No action required on this PR, just a note for future PRs.

Copy link
Member Author

Choose a reason for hiding this comment

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

Agreed. Splitting the PRs is actually not that hard, so I did it here: #1500.

let config: TransactionMetricsConfig = serde_json::from_str(
r#"
{
"version": 1,
"extractMetrics": [
Copy link
Member Author

Choose a reason for hiding this comment

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

TODO: remove extractMetrics from all test cases.

Base automatically changed from feat/limit-custom-measurements to master September 22, 2022 11:41
@jjbayer jjbayer marked this pull request as ready for review September 23, 2022 11:15
@jjbayer jjbayer requested a review from a team September 23, 2022 11:15
@jjbayer jjbayer assigned iker-barriocanal and unassigned jjbayer Sep 23, 2022
Copy link
Contributor

@iker-barriocanal iker-barriocanal left a comment

Choose a reason for hiding this comment

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

Not blocking, but I want to understand the removal of total.time first.

Comment on lines +415 to +419
if measurement_name == "total.time" {
// The only reason we do not emit total.time as a metric is that is was not
// on the allowlist in sentry before, and nobody seems to be missing it.
continue;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't understand why we should remove it. If it's not in the allowlist and a user adds it, my expectation is either to treat is as a custom measurement or to just not support it (e.g. it could be a typo).

Copy link
Member Author

Choose a reason for hiding this comment

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

total.time is a special case because it is generated by Relay itself:

let total_time_value = Annotated::new(Measurement {
value: Annotated::new(relay_common::duration_to_millis(total_time)),
unit: Annotated::new(MetricUnit::Duration(DurationUnit::MilliSecond)),
});
breakdown.insert("total.time".to_string(), total_time_value);

Even if a user sets it, Relay overwrites it.

It probably makes sense to extract total.time as a metric, but there are three reasons why I wouldn't do it in this PR:

  1. It was previously not in the allowlist, and I don't want this PR to change anything about our externally visible behavior in production.
  2. Since total.time is generated by Relay, we would now emit an additional metric for every transaction that has breakdowns, something that we should coordinate with storage.
  3. (more practical): There is an integration test that will break Relay CI if we add a metric: https://github.com/getsentry/sentry/blob/72ed3980d2113aed3c44d7bcec18d1d7513c074f/tests/relay_integration/test_metrics_extraction.py#L14. This is fine if we want to deliberately add the metric, but I think that should be a separate PR.

cc @jan-auer

Copy link
Contributor

Choose a reason for hiding this comment

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

Sounds good, thanks for the explanation.

Out of the scope of the PR, but we should make a decision on if we want to keep it or not. If nobody misses it (or can be calculated from other metrics), we can remove it from the codebase instead of generating and discarding it.

assert_eq!(metric.tags["platform"], "javascript");
assert!(!metric.tags.contains_key("bogus"));
}
insta::assert_debug_snapshot!(metrics, @r###"
Copy link
Contributor

Choose a reason for hiding this comment

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

The test diff is large because a few tests used the metrics allowlist to filter down metrics returned.

Definitely out of the scope of this PR, but tests should not interfere with other tests.

assert_eq!(metric.tags["platform"], "javascript");
assert!(!metric.tags.contains_key("bogus"));
}
insta::assert_debug_snapshot!(metrics, @r###"
Copy link
Contributor

Choose a reason for hiding this comment

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

I like using snapshots (vs ad-hoc asserts) a lot. However, making this change in this PR makes focusing on the relevant aspects harder, vs having another PR for the refactor. No action required on this PR, just a note for future PRs.

tests/integration/test_metrics.py Outdated Show resolved Hide resolved
tests/integration/test_metrics.py Show resolved Hide resolved
Co-authored-by: Iker Barriocanal <32816711+iker-barriocanal@users.noreply.github.com>
@jjbayer jjbayer assigned iker-barriocanal and unassigned jjbayer Sep 26, 2022
jjbayer added a commit that referenced this pull request Sep 26, 2022
Replacing ad-hoc asserts in tests with `insta::assert_debug_snapshot!`
should improve readability and make it easier to adapt the tests when
functionality changes (see #1484).
Comment on lines +415 to +419
if measurement_name == "total.time" {
// The only reason we do not emit total.time as a metric is that is was not
// on the allowlist in sentry before, and nobody seems to be missing it.
continue;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Sounds good, thanks for the explanation.

Out of the scope of the PR, but we should make a decision on if we want to keep it or not. If nobody misses it (or can be calculated from other metrics), we can remove it from the codebase instead of generating and discarding it.

@jjbayer jjbayer merged commit be12cd4 into master Sep 27, 2022
@jjbayer jjbayer deleted the feat/ignore-metrics-allowlist branch September 27, 2022 10:52
jan-auer added a commit that referenced this pull request Sep 27, 2022
* master:
  feat(metrics): Ignore transaction metrics allowlist  (#1484)
  ref(metrics): Remove long running futures (#1492)
  ref(metrics): Convert metrics tests to insta (#1500)
  doc(metrics): Add bucket width to examples (#1496)
jjbayer added a commit that referenced this pull request Sep 27, 2022
jjbayer added a commit that referenced this pull request Sep 27, 2022
In #1484, we stopped using the old project config entries
`transactionMetrics.extractMetrics` and
`transactionMetrics.customMeasurements` because they have become
unnecessary for Relay.

However, they are needed by outdated downstream Relays to function
correctly, so they should be part of the project configs we serialize
for use in downstream instances.
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.

3 participants