Class MetricsHelper

java.lang.Object
io.sentry.metrics.MetricsHelper

@Internal public final class MetricsHelper extends Object
  • Field Details

  • Constructor Details

    • MetricsHelper

      public MetricsHelper()
  • Method Details

    • getTimeBucketKey

      public static long getTimeBucketKey(long timestampMs)
    • getCutoffTimestampMs

      public static long getCutoffTimestampMs(long nowMs)
    • sanitizeUnit

      @NotNull public static @NotNull String sanitizeUnit(@NotNull @NotNull String unit)
    • sanitizeName

      @NotNull public static @NotNull String sanitizeName(@NotNull @NotNull String input)
    • sanitizeTagKey

      @NotNull public static @NotNull String sanitizeTagKey(@NotNull @NotNull String input)
    • sanitizeTagValue

      @NotNull public static @NotNull String sanitizeTagValue(@NotNull @NotNull String input)
    • 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 type
      key - the metric key
      unit - the metric unit
      Returns:
      the export key
    • convertNanosTo

      public static double convertNanosTo(@NotNull MeasurementUnit.Duration unit, long durationNanos)
    • encodeMetrics

      public static void encodeMetrics(long timestamp, @NotNull @NotNull Collection<Metric> metrics, @NotNull @NotNull StringBuilder writer)
      Encodes the metrics

      See 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 resolution
      metrics - The metrics to encode
      writer - The writer to encode the metrics into
    • mergeTags

      @NotNull public static @NotNull Map<String,String> mergeTags(@Nullable @Nullable Map<String,String> tags, @NotNull @NotNull Map<String,String> defaultTags)
    • setFlushShiftMs

      @TestOnly public static void setFlushShiftMs(long flushShiftMs)