|
| 1 | +package io.sentry; |
| 2 | + |
| 3 | +import java.io.Closeable; |
| 4 | +import java.util.Map; |
| 5 | +import org.jetbrains.annotations.NotNull; |
| 6 | +import org.jetbrains.annotations.Nullable; |
| 7 | + |
| 8 | +public interface IMetricsAggregator extends Closeable { |
| 9 | + |
| 10 | + /** |
| 11 | + * Emits a Counter metric |
| 12 | + * |
| 13 | + * @param key A unique key identifying the metric |
| 14 | + * @param value The value to be added |
| 15 | + * @param unit An optional unit, see {@link MeasurementUnit} |
| 16 | + * @param tags Optional Tags to associate with the metric |
| 17 | + * @param timestampMs The time when the metric was emitted. Defaults to the time at which the |
| 18 | + * metric is emitted, if no value is provided. |
| 19 | + * @param stackLevel Optional number of stacks levels to ignore when determining the code location |
| 20 | + */ |
| 21 | + void increment( |
| 22 | + final @NotNull String key, |
| 23 | + final double value, |
| 24 | + final @Nullable MeasurementUnit unit, |
| 25 | + final @Nullable Map<String, String> tags, |
| 26 | + final long timestampMs, |
| 27 | + final int stackLevel); |
| 28 | + |
| 29 | + /** |
| 30 | + * Emits a Gauge metric |
| 31 | + * |
| 32 | + * @param key A unique key identifying the metric |
| 33 | + * @param value The value to be added |
| 34 | + * @param unit An optional unit, see {@link MeasurementUnit} |
| 35 | + * @param tags Optional Tags to associate with the metric |
| 36 | + * @param timestampMs The time when the metric was emitted. Defaults to the time at which the |
| 37 | + * metric is emitted, if no value is provided. |
| 38 | + * @param stackLevel Optional number of stacks levels to ignore when determining the code location |
| 39 | + */ |
| 40 | + void gauge( |
| 41 | + final @NotNull String key, |
| 42 | + final double value, |
| 43 | + final @Nullable MeasurementUnit unit, |
| 44 | + final @Nullable Map<String, String> tags, |
| 45 | + final long timestampMs, |
| 46 | + final int stackLevel); |
| 47 | + |
| 48 | + /** |
| 49 | + * Emits a Distribution metric |
| 50 | + * |
| 51 | + * @param key A unique key identifying the metric |
| 52 | + * @param value The value to be added |
| 53 | + * @param unit An optional unit, see {@link MeasurementUnit} |
| 54 | + * @param tags Optional Tags to associate with the metric |
| 55 | + * @param timestampMs The time when the metric was emitted. Defaults to the time at which the |
| 56 | + * metric is emitted, if no value is provided. |
| 57 | + * @param stackLevel Optional number of stacks levels to ignore when determining the code location |
| 58 | + */ |
| 59 | + void distribution( |
| 60 | + final @NotNull String key, |
| 61 | + final double value, |
| 62 | + final @Nullable MeasurementUnit unit, |
| 63 | + final @Nullable Map<String, String> tags, |
| 64 | + final long timestampMs, |
| 65 | + final int stackLevel); |
| 66 | + |
| 67 | + /** |
| 68 | + * Emits a Set metric |
| 69 | + * |
| 70 | + * @param key A unique key identifying the metric |
| 71 | + * @param value The value to be added |
| 72 | + * @param unit An optional unit, see {@link MeasurementUnit} |
| 73 | + * @param tags Optional Tags to associate with the metric |
| 74 | + * @param timestampMs The time when the metric was emitted. Defaults to the time at which the |
| 75 | + * metric is emitted, if no value is provided. |
| 76 | + * @param stackLevel Optional number of stacks levels to ignore when determining the code location |
| 77 | + */ |
| 78 | + void set( |
| 79 | + final @NotNull String key, |
| 80 | + final int value, |
| 81 | + final @Nullable MeasurementUnit unit, |
| 82 | + final @Nullable Map<String, String> tags, |
| 83 | + final long timestampMs, |
| 84 | + final int stackLevel); |
| 85 | + |
| 86 | + /** |
| 87 | + * Emits a Set metric |
| 88 | + * |
| 89 | + * @param key A unique key identifying the metric |
| 90 | + * @param value The value to be added |
| 91 | + * @param unit An optional unit, see {@link MeasurementUnit} |
| 92 | + * @param tags Optional Tags to associate with the metric |
| 93 | + * @param timestampMs The time when the metric was emitted. Defaults to the time at which the |
| 94 | + * metric is emitted, if no value is provided. |
| 95 | + * @param stackLevel Optional number of stacks levels to ignore when determining the code location |
| 96 | + */ |
| 97 | + void set( |
| 98 | + final @NotNull String key, |
| 99 | + final @NotNull String value, |
| 100 | + final @Nullable MeasurementUnit unit, |
| 101 | + final @Nullable Map<String, String> tags, |
| 102 | + final long timestampMs, |
| 103 | + final int stackLevel); |
| 104 | + |
| 105 | + /** |
| 106 | + * Emits a distribution with the time it takes to run a given code block. |
| 107 | + * |
| 108 | + * @param key A unique key identifying the metric |
| 109 | + * @param callback The code block to measure |
| 110 | + * @param unit An optional unit, see {@link MeasurementUnit.Duration}, defaults to seconds |
| 111 | + * @param tags Optional Tags to associate with the metric |
| 112 | + * @param stackLevel Optional number of stacks levels to ignore when determining the code location |
| 113 | + */ |
| 114 | + void timing( |
| 115 | + final @NotNull String key, |
| 116 | + final @NotNull Runnable callback, |
| 117 | + final @NotNull MeasurementUnit.Duration unit, |
| 118 | + final @Nullable Map<String, String> tags, |
| 119 | + final int stackLevel); |
| 120 | + |
| 121 | + void flush(boolean force); |
| 122 | +} |
0 commit comments