-
-
Notifications
You must be signed in to change notification settings - Fork 455
Add metrics API #3205
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
Add metrics API #3205
Changes from all commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
4f5b71f
Implement different metric types, add API and aggregator
markushi 1d9aca3
Fix typos, make executorService volatile
markushi 98b01f0
Move from Calendar to long timestamps, add hooks for testing
markushi 1809236
Rename to metrics, have Sentry.metrics() as entry point
markushi 72ceeee
Add more tests, use cr32 for hashing strings
markushi 0f79074
Merge branch 'main' into feat/metrics
markushi 64445a6
Enrich tags, add more tests
markushi 1a21cf5
Cleanup tests and timing API, remove uneeded threadlocal
markushi 2730784
Update changelog
markushi d24e95a
Merge branch 'main' into feat/metrics
markushi 64b6efc
Move default tag generation to IMetricsHub, improve dx
markushi 02abee8
Cleanup
markushi c371cea
Cleanup
markushi 3af988e
Fix remove duplicate metricAggregator.close call
markushi 3e88d48
Address PR feedback
markushi bbb4501
Merge branch 'main' into feat/metrics
markushi 01412ab
Move test into metrics helper
markushi 9c67a6c
Rename getValues to serialize to match API spec
markushi 6a3be45
Add support for force-flushing metrics when weight is too high
markushi 43d1319
Merge branch 'main' into feat/metrics
markushi cb0a002
Update Changelog
markushi 07fc4e5
Revert "Add support for force-flushing metrics when weight is too high"
markushi 3da6982
Fix .api
markushi 576450e
Fix tests
markushi 43305ed
Fix remove test code
markushi 860dc55
Merge branch 'main' into feat/metrics
markushi 84466fd
Merge branch 'main' into feat/metrics
markushi 4fddc57
Replace tag values with empty string
markushi fcff268
Address PR feedback
markushi 86b3ffa
Format & API
markushi 1788aaf
Fix tests
markushi 9b1f4aa
Force flush metrics when aggregator exceeds max weight (#3220)
markushi 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
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
Large diffs are not rendered by default.
Oops, something went wrong.
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
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,122 @@ | ||
package io.sentry; | ||
|
||
import java.io.Closeable; | ||
import java.util.Map; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
public interface IMetricsAggregator extends Closeable { | ||
|
||
/** | ||
* Emits a Counter metric | ||
* | ||
* @param key A unique key identifying the metric | ||
* @param value The value to be added | ||
* @param unit An optional unit, see {@link MeasurementUnit} | ||
* @param tags Optional Tags to associate with the metric | ||
* @param timestampMs The time when the metric was emitted. Defaults to the time at which the | ||
* metric is emitted, if no value is provided. | ||
* @param stackLevel Optional number of stacks levels to ignore when determining the code location | ||
*/ | ||
void increment( | ||
final @NotNull String key, | ||
final double value, | ||
final @Nullable MeasurementUnit unit, | ||
final @Nullable Map<String, String> tags, | ||
final long timestampMs, | ||
final int stackLevel); | ||
|
||
/** | ||
* Emits a Gauge metric | ||
* | ||
* @param key A unique key identifying the metric | ||
* @param value The value to be added | ||
* @param unit An optional unit, see {@link MeasurementUnit} | ||
* @param tags Optional Tags to associate with the metric | ||
* @param timestampMs The time when the metric was emitted. Defaults to the time at which the | ||
* metric is emitted, if no value is provided. | ||
* @param stackLevel Optional number of stacks levels to ignore when determining the code location | ||
*/ | ||
void gauge( | ||
final @NotNull String key, | ||
final double value, | ||
final @Nullable MeasurementUnit unit, | ||
final @Nullable Map<String, String> tags, | ||
final long timestampMs, | ||
final int stackLevel); | ||
|
||
/** | ||
* Emits a Distribution metric | ||
* | ||
* @param key A unique key identifying the metric | ||
* @param value The value to be added | ||
* @param unit An optional unit, see {@link MeasurementUnit} | ||
* @param tags Optional Tags to associate with the metric | ||
* @param timestampMs The time when the metric was emitted. Defaults to the time at which the | ||
* metric is emitted, if no value is provided. | ||
* @param stackLevel Optional number of stacks levels to ignore when determining the code location | ||
*/ | ||
void distribution( | ||
final @NotNull String key, | ||
final double value, | ||
final @Nullable MeasurementUnit unit, | ||
final @Nullable Map<String, String> tags, | ||
final long timestampMs, | ||
final int stackLevel); | ||
|
||
/** | ||
* Emits a Set metric | ||
* | ||
* @param key A unique key identifying the metric | ||
* @param value The value to be added | ||
* @param unit An optional unit, see {@link MeasurementUnit} | ||
* @param tags Optional Tags to associate with the metric | ||
* @param timestampMs The time when the metric was emitted. Defaults to the time at which the | ||
* metric is emitted, if no value is provided. | ||
* @param stackLevel Optional number of stacks levels to ignore when determining the code location | ||
*/ | ||
void set( | ||
final @NotNull String key, | ||
final int value, | ||
final @Nullable MeasurementUnit unit, | ||
final @Nullable Map<String, String> tags, | ||
final long timestampMs, | ||
final int stackLevel); | ||
|
||
/** | ||
* Emits a Set metric | ||
* | ||
* @param key A unique key identifying the metric | ||
* @param value The value to be added | ||
* @param unit An optional unit, see {@link MeasurementUnit} | ||
* @param tags Optional Tags to associate with the metric | ||
* @param timestampMs The time when the metric was emitted. Defaults to the time at which the | ||
* metric is emitted, if no value is provided. | ||
* @param stackLevel Optional number of stacks levels to ignore when determining the code location | ||
*/ | ||
void set( | ||
final @NotNull String key, | ||
final @NotNull String value, | ||
final @Nullable MeasurementUnit unit, | ||
final @Nullable Map<String, String> tags, | ||
final long timestampMs, | ||
final int stackLevel); | ||
|
||
/** | ||
* Emits a distribution with the time it takes to run a given code block. | ||
* | ||
* @param key A unique key identifying the metric | ||
* @param callback The code block to measure | ||
* @param unit An optional unit, see {@link MeasurementUnit.Duration}, defaults to seconds | ||
* @param tags Optional Tags to associate with the metric | ||
* @param stackLevel Optional number of stacks levels to ignore when determining the code location | ||
*/ | ||
void timing( | ||
final @NotNull String key, | ||
final @NotNull Runnable callback, | ||
final @NotNull MeasurementUnit.Duration unit, | ||
final @Nullable Map<String, String> tags, | ||
final int stackLevel); | ||
|
||
void flush(boolean force); | ||
} |
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.