Package io.sentry.metrics
Class MetricsHelper
java.lang.Object
io.sentry.metrics.MetricsHelper
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final longstatic final int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic doubleconvertNanosTo(MeasurementUnit.Duration unit, long durationNanos) static voidencodeMetrics(long timestamp, @NotNull Collection<Metric> metrics, @NotNull StringBuilder writer) Encodes the metricsstatic longgetCutoffTimestampMs(long nowMs) static @NotNull StringgetExportKey(@NotNull MetricType type, @NotNull String key, @Nullable MeasurementUnit unit) Provides an export key for identifying the metric without its tags.static @NotNull StringgetMetricBucketKey(@NotNull MetricType type, @NotNull String metricKey, @Nullable MeasurementUnit unit, @Nullable Map<String, String> tags) static longgetTimeBucketKey(long timestampMs) static @NotNull StringsanitizeName(@NotNull String input) static @NotNull StringsanitizeTagKey(@NotNull String input) static @NotNull StringsanitizeTagValue(@NotNull String input) static @NotNull StringsanitizeUnit(@NotNull String unit) static voidsetFlushShiftMs(long flushShiftMs)
-
Field Details
-
FLUSHER_SLEEP_TIME_MS
public static final long FLUSHER_SLEEP_TIME_MS- See Also:
-
MAX_TOTAL_WEIGHT
public static final int MAX_TOTAL_WEIGHT- See Also:
-
-
Constructor Details
-
MetricsHelper
public MetricsHelper()
-
-
Method Details
-
getTimeBucketKey
public static long getTimeBucketKey(long timestampMs) -
getCutoffTimestampMs
public static long getCutoffTimestampMs(long nowMs) -
sanitizeUnit
-
sanitizeName
-
sanitizeTagKey
-
sanitizeTagValue
-
getMetricBucketKey
@NotNull public static @NotNull String getMetricBucketKey(@NotNull @NotNull MetricType type, @NotNull @NotNull String metricKey, @Nullable @Nullable MeasurementUnit unit, @Nullable @Nullable Map<String, String> tags) -
getExportKey
@NotNull public static @NotNull String getExportKey(@NotNull @NotNull MetricType type, @NotNull @NotNull String key, @Nullable @Nullable MeasurementUnit unit) Provides an export key for identifying the metric without its tags. Suitable for span level metric summaries- Parameters:
type- the metric typekey- the metric keyunit- the metric unit- Returns:
- the export key
-
convertNanosTo
-
encodeMetrics
public static void encodeMetrics(long timestamp, @NotNull @NotNull Collection<Metric> metrics, @NotNull @NotNull StringBuilder writer) Encodes the metricsSee github.com/statsd/statsd#usage and getsentry.github.io/relay/relay_metrics/index.html for more details about the format.
- Parameters:
timestamp- The bucket time the metrics belong to, in second resolutionmetrics- The metrics to encodewriter- The writer to encode the metrics into
-
mergeTags
-
setFlushShiftMs
@TestOnly public static void setFlushShiftMs(long flushShiftMs)
-