-
-
Notifications
You must be signed in to change notification settings - Fork 466
feat(metrics): [Trace Metrics 1] Metrics Options #4980
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
base: main
Are you sure you want to change the base?
Changes from all commits
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 |
|---|---|---|
|
|
@@ -624,6 +624,8 @@ public class SentryOptions { | |
|
|
||
| private @NotNull SentryOptions.Logs logs = new SentryOptions.Logs(); | ||
|
|
||
| private @NotNull SentryOptions.Metrics metrics = new SentryOptions.Metrics(); | ||
|
|
||
| private @NotNull ISocketTagger socketTagger = NoOpSocketTagger.getInstance(); | ||
|
|
||
| /** Runtime manager to manage runtime policies, like StrictMode on Android. */ | ||
|
|
@@ -3261,20 +3263,6 @@ public interface BeforeEnvelopeCallback { | |
| void execute(@NotNull SentryEnvelope envelope, @Nullable Hint hint); | ||
| } | ||
|
|
||
| /** The BeforeEmitMetric callback */ | ||
| @ApiStatus.Experimental | ||
| public interface BeforeEmitMetricCallback { | ||
|
|
||
| /** | ||
| * A callback which gets called right before a metric is about to be emitted. | ||
| * | ||
| * @param key the metric key | ||
| * @param tags the metric tags | ||
| * @return true if the metric should be emitted, false otherwise | ||
| */ | ||
| boolean execute(@NotNull String key, @Nullable Map<String, String> tags); | ||
| } | ||
|
|
||
| /** | ||
| * Creates SentryOptions instance without initializing any of the internal parts. | ||
| * | ||
|
|
@@ -3537,6 +3525,16 @@ public void setLogs(@NotNull SentryOptions.Logs logs) { | |
| this.logs = logs; | ||
| } | ||
|
|
||
| @ApiStatus.Experimental | ||
| public @NotNull SentryOptions.Metrics getMetrics() { | ||
| return metrics; | ||
| } | ||
|
|
||
| @ApiStatus.Experimental | ||
| public void setMetrics(@NotNull SentryOptions.Metrics metrics) { | ||
| this.metrics = metrics; | ||
| } | ||
|
|
||
| public static final class Proxy { | ||
| private @Nullable String host; | ||
| private @Nullable String port; | ||
|
|
@@ -3741,6 +3739,67 @@ public interface BeforeSendLogCallback { | |
| } | ||
| } | ||
|
|
||
| public static final class Metrics { | ||
|
|
||
| /** Whether Sentry Metrics feature is enabled and metrics are sent to Sentry. */ | ||
| private boolean enable = false; | ||
|
Member
Author
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. changed to true in a follow up PR |
||
|
|
||
| /** | ||
| * This function is called with a metric key and tags and can return false to skip sending the | ||
| * metric | ||
| */ | ||
| private @Nullable BeforeSendMetricCallback beforeSend; | ||
|
|
||
| /** | ||
| * Whether Sentry Metrics feature is enabled and metrics are sent to Sentry. | ||
| * | ||
| * @return true if Sentry Metrics should be enabled | ||
| */ | ||
| public boolean isEnabled() { | ||
| return enable; | ||
| } | ||
|
|
||
| /** | ||
| * Whether Sentry Metrics feature is enabled and metrics are sent to Sentry. | ||
| * | ||
| * @param enableMetrics true if Sentry Metrics should be enabled | ||
| */ | ||
| public void setEnabled(boolean enableMetrics) { | ||
| this.enable = enableMetrics; | ||
| } | ||
|
|
||
| /** | ||
| * Returns the BeforeSendMetric callback | ||
| * | ||
| * @return the beforeSend callback or null if not set | ||
| */ | ||
| public @Nullable BeforeSendMetricCallback getBeforeSend() { | ||
| return beforeSend; | ||
| } | ||
|
|
||
| /** | ||
| * Sets the beforeSend callback for metrics | ||
| * | ||
| * @param beforeSend the beforeSend callback for metrics | ||
| */ | ||
| public void setBeforeSend(@Nullable BeforeSendMetricCallback beforeSend) { | ||
| this.beforeSend = beforeSend; | ||
| } | ||
|
|
||
| public interface BeforeSendMetricCallback { | ||
|
|
||
| /** | ||
| * A callback which gets called right before a metric is about to be sent. | ||
| * | ||
| * @param metric the metric | ||
| * @return the original metric, mutated metric or null if metric was dropped | ||
| */ | ||
| // TODO replace with SentryMetric | ||
| @Nullable | ||
| Object execute(@NotNull Object metric); | ||
|
Member
Author
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. Signature updated in follow-up PRs
Member
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. do we need any kind of hint here? just wondering if it makes sense to add it now to not break this API in the future in case we need it (i'm imagining if we start sending default metrics like Android's AppExitReasons, the hint could be a good place to expose some information along) |
||
| } | ||
| } | ||
|
|
||
| @ApiStatus.Experimental | ||
| public @NotNull DistributionOptions getDistribution() { | ||
| return distribution; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New APIs should not be marked Experimental