Skip to content

Add support for Sentry Developer Metrics - #1619

Merged
cleptric merged 38 commits into
masterfrom
metrics
Dec 21, 2023
Merged

cleptric merged 38 commits into
masterfrom
metrics

Conversation

@cleptric

@cleptric cleptric commented Oct 31, 2023 •

Copy link
Copy Markdown
Member

This adds support for Sentry Developer Metrics.

See getsentry/sentry#58584

image

use function Sentry\metrics;

// Add 4 to a counter named `hits`
metrics()->increment(key: 'hits', value: 4);

// Add 25 to a distribution named `response_time` with unit milliseconds
metrics()->distribution(key: 'response_time', value: 25, unit: MetricsUnit::millisecond());

// Add 2 to gauge named `parallel_requests`, tagged with `type: "a"`
metrics()->gauge(key: 'parallel_requests, value: 2, tags: ['type': 'a']);

// Add a user's email to a set named users.sessions, tagged with role admin
metrics()->set('users.sessions', '[email protected]', null, ['role' => User::admin()]);

// Flush the metrics to Sentry
metrics()->flush();

// We recommend registering the flushing in a shutdown function
register_shutdown_function(static fn () => metrics()->flush());

In case you're not already enrolled on our Metrics alpha program, please sign up here.

To-Dos

@cleptric
cleptric marked this pull request as draft October 31, 2023 03:52
@cleptric cleptric self-assigned this Oct 31, 2023
@cleptric cleptric added this to the 4.0 milestone Oct 31, 2023
@cleptric
cleptric force-pushed the metrics branch 2 times, most recently from 62bb5b7 to 46a9089 Compare October 31, 2023 11:49
@cleptric cleptric removed this from the 4.0 milestone Nov 6, 2023
Base automatically changed from 4.x to master November 6, 2023 10:15
@cleptric
cleptric marked this pull request as ready for review November 8, 2023 04:28
@cleptric
cleptric marked this pull request as draft November 10, 2023 12:31
@cleptric

Copy link
Copy Markdown
Member Author

Marking as Draft again, missed some stuff

Comment thread src/Metrics/MetricsAggregator.php Resolved
Comment thread src/Tracing/Span.php Resolved
@cleptric cleptric changed the title Add DDM support Add support for Sentry Developer Metrics Dec 21, 2023

@stayallive stayallive left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

🪨

@cleptric
cleptric requested a review from mitsuhiko December 21, 2023 14:28
@HazAT
HazAT marked this pull request as ready for review December 21, 2023 14:36
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