Class MetricsApi

java.lang.Object
io.sentry.metrics.MetricsApi

public final class MetricsApi extends Object
  • Constructor Details

  • Method Details

    • increment

      public void increment(@NotNull @NotNull String key)
      Emits an increment of 1.0 for a counter
      Parameters:
      key - A unique key identifying the metric
    • increment

      public void increment(@NotNull @NotNull String key, double value)
      Emits a Counter metric
      Parameters:
      key - A unique key identifying the metric
      value - The value to be added
    • increment

      public void increment(@NotNull @NotNull String key, double value, @Nullable @Nullable MeasurementUnit unit)
      Emits a Counter metric
      Parameters:
      key - A unique key identifying the metric
      value - The value to be added
      unit - An optional unit, see MeasurementUnit
    • increment

      public void increment(@NotNull @NotNull String key, double value, @Nullable @Nullable MeasurementUnit unit, @Nullable @Nullable Map<String,String> tags)
      Emits a Counter metric
      Parameters:
      key - A unique key identifying the metric
      value - The value to be added
      unit - An optional unit, see MeasurementUnit
      tags - Optional Tags to associate with the metric
    • increment

      public void increment(@NotNull @NotNull String key, double value, @Nullable @Nullable MeasurementUnit unit, @Nullable @Nullable Map<String,String> tags, @Nullable @Nullable Long timestampMs)
      Emits a Counter metric
      Parameters:
      key - A unique key identifying the metric
      value - The value to be added
      unit - An optional unit, see MeasurementUnit
      tags - Optional Tags to associate with the metric
      timestampMs - The time when the metric was emitted. Defaults to the time at which the metric is emitted, if no value is provided.
    • gauge

      public void gauge(@NotNull @NotNull String key, double value)
      Emits a Gauge metric
      Parameters:
      key - A unique key identifying the metric
      value - The value to be added
    • gauge

      public void gauge(@NotNull @NotNull String key, double value, @Nullable @Nullable MeasurementUnit unit)
      Emits a Gauge metric
      Parameters:
      key - A unique key identifying the metric
      value - The value to be added
      unit - An optional unit, see MeasurementUnit
    • gauge

      public void gauge(@NotNull @NotNull String key, double value, @Nullable @Nullable MeasurementUnit unit, @Nullable @Nullable Map<String,String> tags)
      Emits a Gauge metric
      Parameters:
      key - A unique key identifying the metric
      value - The value to be added
      unit - An optional unit, see MeasurementUnit
      tags - Optional Tags to associate with the metric
    • gauge

      public void gauge(@NotNull @NotNull String key, double value, @Nullable @Nullable MeasurementUnit unit, @Nullable @Nullable Map<String,String> tags, @Nullable @Nullable Long timestampMs)
      Emits a Gauge metric
      Parameters:
      key - A unique key identifying the metric
      value - The value to be added
      unit - An optional unit, see MeasurementUnit
      tags - Optional Tags to associate with the metric
      timestampMs - The time when the metric was emitted. Defaults to the time at which the metric is emitted, if no value is provided.
    • distribution

      public void distribution(@NotNull @NotNull String key, double value)
      Emits a Distribution metric
      Parameters:
      key - A unique key identifying the metric
      value - The value to be added
    • distribution

      public void distribution(@NotNull @NotNull String key, double value, @Nullable @Nullable MeasurementUnit unit)
      Emits a Distribution metric
      Parameters:
      key - A unique key identifying the metric
      value - The value to be added
      unit - An optional unit, see MeasurementUnit
    • distribution

      public void distribution(@NotNull @NotNull String key, double value, @Nullable @Nullable MeasurementUnit unit, @Nullable @Nullable Map<String,String> tags)
      Emits a Distribution metric
      Parameters:
      key - A unique key identifying the metric
      value - The value to be added
      unit - An optional unit, see MeasurementUnit
      tags - Optional Tags to associate with the metric
    • distribution

      public void distribution(@NotNull @NotNull String key, double value, @Nullable @Nullable MeasurementUnit unit, @Nullable @Nullable Map<String,String> tags, @Nullable @Nullable Long timestampMs)
      Emits a Distribution metric
      Parameters:
      key - A unique key identifying the metric
      value - The value to be added
      unit - An optional unit, see MeasurementUnit
      tags - Optional Tags to associate with the metric
      timestampMs - The time when the metric was emitted. Defaults to the time at which the metric is emitted, if no value is provided.
    • set

      public void set(@NotNull @NotNull String key, int value)
      Emits a Set metric
      Parameters:
      key - A unique key identifying the metric
      value - The value to be added
    • set

      public void set(@NotNull @NotNull String key, int value, @Nullable @Nullable MeasurementUnit unit)
      Emits a Set metric
      Parameters:
      key - A unique key identifying the metric
      value - The value to be added
      unit - An optional unit, see MeasurementUnit
    • set

      public void set(@NotNull @NotNull String key, int value, @Nullable @Nullable MeasurementUnit unit, @Nullable @Nullable Map<String,String> tags)
      Emits a Set metric
      Parameters:
      key - A unique key identifying the metric
      value - The value to be added
      unit - An optional unit, see MeasurementUnit
      tags - Optional Tags to associate with the metric
    • set

      public void set(@NotNull @NotNull String key, int value, @Nullable @Nullable MeasurementUnit unit, @Nullable @Nullable Map<String,String> tags, @Nullable @Nullable Long timestampMs)
      Emits a Set metric
      Parameters:
      key - A unique key identifying the metric
      value - The value to be added
      unit - An optional unit, see MeasurementUnit
      tags - Optional Tags to associate with the metric
      timestampMs - The time when the metric was emitted. Defaults to the time at which the metric is emitted, if no value is provided.
    • set

      public void set(@NotNull @NotNull String key, @NotNull @NotNull String value)
      Emits a Set metric
      Parameters:
      key - A unique key identifying the metric
      value - The value to be added
    • set

      public void set(@NotNull @NotNull String key, @NotNull @NotNull String value, @Nullable @Nullable MeasurementUnit unit)
      Emits a Set metric
      Parameters:
      key - A unique key identifying the metric
      value - The value to be added
      unit - An optional unit, see MeasurementUnit
    • set

      public void set(@NotNull @NotNull String key, @NotNull @NotNull String value, @Nullable @Nullable MeasurementUnit unit, @Nullable @Nullable Map<String,String> tags)
      Emits a Set metric
      Parameters:
      key - A unique key identifying the metric
      value - The value to be added
      unit - An optional unit, see MeasurementUnit
      tags - Optional Tags to associate with the metric
    • set

      public void set(@NotNull @NotNull String key, @NotNull @NotNull String value, @Nullable @Nullable MeasurementUnit unit, @Nullable @Nullable Map<String,String> tags, @Nullable @Nullable Long timestampMs)
      Emits a Set metric
      Parameters:
      key - A unique key identifying the metric
      value - The value to be added
      unit - An optional unit, see MeasurementUnit
      tags - Optional Tags to associate with the metric
      timestampMs - The time when the metric was emitted. Defaults to the time at which the metric is emitted, if no value is provided.
    • timing

      public void timing(@NotNull @NotNull String key, @NotNull @NotNull Runnable callback)
      Emits a distribution with the time it takes to run a given code block.
      Parameters:
      key - A unique key identifying the metric
      callback - The code block to measure
    • timing

      public void timing(@NotNull @NotNull String key, @NotNull @NotNull Runnable callback, @NotNull MeasurementUnit.Duration unit)
      Emits a distribution with the time it takes to run a given code block.
      Parameters:
      key - A unique key identifying the metric
      callback - The code block to measure
      unit - An optional unit, see MeasurementUnit.Duration
    • timing

      public void timing(@NotNull @NotNull String key, @NotNull @NotNull Runnable callback, @Nullable MeasurementUnit.Duration unit, @Nullable @Nullable Map<String,String> tags)
      Emits a distribution with the time it takes to run a given code block.
      Parameters:
      key - A unique key identifying the metric
      callback - The code block to measure
      unit - An optional unit, see MeasurementUnit.Duration
      tags - Optional Tags to associate with the metric