-
-
Notifications
You must be signed in to change notification settings - Fork 225
Metrics Support - alpha #2949
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
Merged
Merged
Metrics Support - alpha #2949
Changes from 22 commits
Commits
Show all changes
60 commits
Select commit
Hold shift + click to select a range
5794a6c
Added basic metric types
jamescrosswell 3752fd5
Moved Metric classes
jamescrosswell 0d6587b
Added Increment aggregator
jamescrosswell 088e4fd
Implemented Gauge metric
jamescrosswell 9fac649
Implemented Distribution and Set aggregations
jamescrosswell c65355d
Added Metrics to ISentryClient API
jamescrosswell b77c04d
Update Hub.cs
jamescrosswell c0233db
Verify tests
jamescrosswell 3b74b80
Basic flush loop (no tests yet)
jamescrosswell c83e9c9
Implemented statsd serialization
jamescrosswell 9150098
Update CHANGELOG.md
jamescrosswell 19dc74a
Split tests for Aggregagtor and BucketHelper
jamescrosswell cac0d79
Update MetricBucketHelperTests.cs
jamescrosswell 721e6b3
Integrated review feedback
jamescrosswell a7ba47e
Create MetricTests.verify.cs
jamescrosswell 90be220
Updated verify tests
jamescrosswell 73be790
Merge branch 'main' into metrics
jamescrosswell 94790d7
Added Timing
jamescrosswell e05f8ee
Merge branch 'metrics' of github.com:getsentry/sentry-dotnet into met…
jamescrosswell 54af5c2
Added a (commented out) test to check if the aggregator is threadsafe
jamescrosswell 9344f38
Fixed concurrency issue (could still make this more performant)
jamescrosswell 5827608
Reduced the scope of the lock for updating metrics
jamescrosswell f3275ac
Fixed unit tests
jamescrosswell 0f86158
Update MetricAggregator.cs
jamescrosswell 7a75155
Initial implementation of Code Locations
jamescrosswell a116f56
Merge branch 'main' into metrics
jamescrosswell 7f47f1a
Update Program.cs
jamescrosswell cd83a4e
Updated solution filters
jamescrosswell 826a413
Update CHANGELOG.md
jamescrosswell 994b8ba
Changed Flush to FlushAsync
jamescrosswell 8e7f0ce
Metrics now get flushed properly when disposing of the Hub
jamescrosswell aa3682f
Fixed serialization for code locations
jamescrosswell d9918d8
Update Timing.cs
jamescrosswell 6de5909
Clear stale seen periods at the end of each day
jamescrosswell d180a9d
Update CodeLocations.cs
jamescrosswell 2a6f344
Fixed stacklevel when calling one of the two Timing constructors
jamescrosswell 052c7a9
Removed IAsyncDisposable from MetricAggregator
jamescrosswell 82469ba
Merge branch 'main' into metrics
jamescrosswell 2eedd9c
Cherry picked https://github.com/getsentry/Ben.Demystifier/pull/4
jamescrosswell 18a08bd
Merge branch 'metrics' of github.com:getsentry/sentry-dotnet into met…
jamescrosswell c72c7e1
Update Ben.Demystifier
jamescrosswell 2a323c5
Get line numbers with stack traces without enhanced stack traces
jamescrosswell 57e2b12
Update Ben.Demystifier
jamescrosswell d2c6cb5
Reversed changes to AspNetCore.Basic sample (unrelated to this PR)
jamescrosswell a9c5d6b
Update Program.cs
jamescrosswell 30ef3b4
Improved the lock when incrementing/adding to existing metrics
jamescrosswell 34a5c3e
Tweaking docs
jamescrosswell 7faa57c
Update CHANGELOG.md
jamescrosswell d956b5d
Integrating review feedback
jamescrosswell 3efab8a
Source generated RegEx in metric helper
jamescrosswell 62a7001
Merge branch 'metrics' of github.com:getsentry/sentry-dotnet into met…
jamescrosswell c68c25c
Update Envelope.cs
jamescrosswell 1c3b275
Merge branch 'main' into metrics
jamescrosswell 4cb9ef7
Review feedback
jamescrosswell 36fe029
Merge branch 'main' into metrics
jamescrosswell 8cc439c
Integrating review feedback
jamescrosswell 705d131
More performant string delimited tags used in the bucket key
jamescrosswell 353a928
Integrating review feedback
jamescrosswell 589c3b2
Integrated review feedback
jamescrosswell bce6e50
Removed unused private field
jamescrosswell File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| namespace Sentry; | ||
|
|
||
| internal class DelegatingMetricAggregator(IMetricAggregator innerAggregator) : IMetricAggregator | ||
jamescrosswell marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| { | ||
| public void Increment(string key, double value = 1, MeasurementUnit? unit = null, IDictionary<string, string>? tags = null, | ||
jamescrosswell marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| DateTime? timestamp = null) => innerAggregator.Increment(key, value, unit, tags, timestamp); | ||
|
|
||
| public void Gauge(string key, double value = 1, MeasurementUnit? unit = null, IDictionary<string, string>? tags = null, | ||
| DateTime? timestamp = null) => innerAggregator.Gauge(key, value, unit, tags, timestamp); | ||
|
|
||
| public void Distribution(string key, double value = 1, MeasurementUnit? unit = null, IDictionary<string, string>? tags = null, | ||
| DateTime? timestamp = null) => innerAggregator.Distribution(key, value, unit, tags, timestamp); | ||
|
|
||
| public void Set(string key, double value = 1, MeasurementUnit? unit = null, IDictionary<string, string>? tags = null, | ||
| DateTime? timestamp = null) => innerAggregator.Set(key, value, unit, tags, timestamp); | ||
|
|
||
| public void Timing(string key, double value, MeasurementUnit.Duration unit = MeasurementUnit.Duration.Second, IDictionary<string, string>? tags = null, | ||
| DateTime? timestamp = null) => innerAggregator.Timing(key, value, unit, tags, timestamp); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| namespace Sentry; | ||
|
|
||
| internal class DisabledMetricAggregator : IMetricAggregator | ||
| { | ||
| public void Increment(string key, double value = 1, MeasurementUnit? unit = null, IDictionary<string, string>? tags = null, | ||
jamescrosswell marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| DateTime? timestamp = null) | ||
| { | ||
| // No Op | ||
| } | ||
|
|
||
| public void Gauge(string key, double value = 1, MeasurementUnit? unit = null, IDictionary<string, string>? tags = null, | ||
| DateTime? timestamp = null) | ||
| { | ||
| // No Op | ||
| } | ||
|
|
||
| public void Distribution(string key, double value = 1, MeasurementUnit? unit = null, IDictionary<string, string>? tags = null, | ||
| DateTime? timestamp = null) | ||
| { | ||
| // No Op | ||
| } | ||
|
|
||
| public void Set(string key, double value = 1, MeasurementUnit? unit = null, IDictionary<string, string>? tags = null, | ||
| DateTime? timestamp = null) | ||
| { | ||
| // No Op | ||
| } | ||
|
|
||
| public void Timing(string key, double value, MeasurementUnit.Duration unit = MeasurementUnit.Duration.Second, IDictionary<string, string>? tags = null, | ||
| DateTime? timestamp = null) | ||
| { | ||
| // No Op | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,103 @@ | ||
| namespace Sentry; | ||
|
|
||
| /// <summary> | ||
| /// Exposes EXPERIMENTAL capability to emit metrics. This API is subject to change without major version bumps so use | ||
| /// with caution. We advise disabling in production at the moment. | ||
| /// </summary> | ||
| public interface IMetricAggregator | ||
| { | ||
| /// <summary> | ||
| /// Emits a Counter metric | ||
| /// </summary> | ||
| /// <param name="key">A unique key identifying the metric</param> | ||
| /// <param name="value">The value to be added</param> | ||
| /// <param name="unit">An optional <see cref="MeasurementUnit"/></param> | ||
| /// <param name="tags">Optional Tags to associate with the metric</param> | ||
| /// <param name="timestamp"> | ||
| /// The time when the metric was emitted. Defaults to the time at which the metric is emitted, if no value is provided. | ||
| /// </param> | ||
| void Increment( | ||
| string key, | ||
| double value = 1.0, | ||
| MeasurementUnit? unit = null, | ||
| IDictionary<string, string>? tags = null, | ||
| DateTime? timestamp = null | ||
| // , int stacklevel = 0 // Used for code locations | ||
| ); | ||
|
|
||
| /// <summary> | ||
| /// Emits a Gauge metric | ||
| /// </summary> | ||
| /// <param name="key">A unique key identifying the metric</param> | ||
| /// <param name="value">The value to be added</param> | ||
| /// <param name="unit">An optional <see cref="MeasurementUnit"/></param> | ||
| /// <param name="tags">Optional Tags to associate with the metric</param> | ||
| /// <param name="timestamp"> | ||
| /// The time when the metric was emitted. Defaults to the time at which the metric is emitted, if no value is provided. | ||
| /// </param> | ||
| void Gauge( | ||
| string key, | ||
| double value = 1.0, | ||
| MeasurementUnit? unit = null, | ||
| IDictionary<string, string>? tags = null, | ||
| DateTime? timestamp = null | ||
| // , int stacklevel = 0 // Used for code locations | ||
| ); | ||
|
|
||
| /// <summary> | ||
| /// Emits a Distribution metric | ||
| /// </summary> | ||
| /// <param name="key">A unique key identifying the metric</param> | ||
| /// <param name="value">The value to be added</param> | ||
| /// <param name="unit">An optional <see cref="MeasurementUnit"/></param> | ||
| /// <param name="tags">Optional Tags to associate with the metric</param> | ||
| /// <param name="timestamp"> | ||
| /// The time when the metric was emitted. Defaults to the time at which the metric is emitted, if no value is provided. | ||
| /// </param> | ||
| void Distribution( | ||
| string key, | ||
| double value = 1.0, | ||
| MeasurementUnit? unit = null, | ||
| IDictionary<string, string>? tags = null, | ||
| DateTime? timestamp = null | ||
| // , int stacklevel = 0 // Used for code locations | ||
| ); | ||
|
|
||
| /// <summary> | ||
| /// Emits a Set metric | ||
| /// </summary> | ||
| /// <param name="key">A unique key identifying the metric</param> | ||
| /// <param name="value">The value to be added</param> | ||
| /// <param name="unit">An optional <see cref="MeasurementUnit"/></param> | ||
| /// <param name="tags">Optional Tags to associate with the metric</param> | ||
| /// <param name="timestamp"> | ||
| /// The time when the metric was emitted. Defaults to the time at which the metric is emitted, if no value is provided. | ||
| /// </param> | ||
| void Set( | ||
| string key, | ||
| double value = 1.0, | ||
jamescrosswell marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| MeasurementUnit? unit = null, | ||
| IDictionary<string, string>? tags = null, | ||
| DateTime? timestamp = null | ||
| // , int stacklevel = 0 // Used for code locations | ||
| ); | ||
|
|
||
| /// <summary> | ||
| /// Emits a distribution with the time it takes to run a given code block. | ||
| /// </summary> | ||
| /// <param name="key">A unique key identifying the metric</param> | ||
| /// <param name="value">The value to be added</param> | ||
| /// <param name="unit"> | ||
| /// An optional <see cref="MeasurementUnit.Duration"/>. Defaults to <see cref="MeasurementUnit.Duration.Second"/> | ||
| /// </param> | ||
| /// <param name="tags">Optional Tags to associate with the metric</param> | ||
| /// <param name="timestamp">The time when the metric was emitted</param> | ||
| void Timing( | ||
| string key, | ||
| double value, | ||
| MeasurementUnit.Duration unit = MeasurementUnit.Duration.Second, | ||
| IDictionary<string, string>? tags = null, | ||
| DateTime? timestamp = null | ||
| // , int stacklevel = 0 // Used for code locations | ||
| ); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.