-
Notifications
You must be signed in to change notification settings - Fork 544
feat(measurements): Add experimental set_measurement api on transaction #1359
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
Changes from all commits
f213d6b
752337e
599fe38
887e85c
9634361
9dd1a48
822ad0f
6b380b8
f79837c
eb44300
cdddfd3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -246,3 +246,31 @@ def test_has_tracestate_enabled(sentry_init, tracestate_enabled): | |
assert has_tracestate_enabled() is True | ||
else: | ||
assert has_tracestate_enabled() is False | ||
|
||
|
||
def test_set_meaurement(sentry_init, capture_events): | ||
sentry_init(traces_sample_rate=1.0, _experiments={"custom_measurements": True}) | ||
|
||
events = capture_events() | ||
|
||
transaction = start_transaction(name="measuring stuff") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if I do:
can I do Or There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Currently they are just on transaction and not span, Open decision is also if we want to expose this on the hub/top-level api as well where it'll just fetch the current hub/scope/transaction and set it there. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree that we should not leak this API to the Child level as well, but a few SDKs return the very same interface for |
||
|
||
with pytest.raises(TypeError): | ||
transaction.set_measurement() | ||
|
||
with pytest.raises(TypeError): | ||
transaction.set_measurement("metric.foo") | ||
|
||
transaction.set_measurement("metric.foo", 123) | ||
transaction.set_measurement("metric.bar", 456, unit="second") | ||
transaction.set_measurement("metric.baz", 420.69, unit="custom") | ||
transaction.set_measurement("metric.foobar", 12, unit="percent") | ||
transaction.set_measurement("metric.foobar", 17.99, unit="percent") | ||
|
||
transaction.finish() | ||
|
||
(event,) = events | ||
assert event["measurements"]["metric.foo"] == {"value": 123, "unit": ""} | ||
assert event["measurements"]["metric.bar"] == {"value": 456, "unit": "second"} | ||
assert event["measurements"]["metric.baz"] == {"value": 420.69, "unit": "custom"} | ||
assert event["measurements"]["metric.foobar"] == {"value": 17.99, "unit": "percent"} |
Uh oh!
There was an error while loading. Please reload this page.