Class Instrumentation

java.lang.Object
io.mishmash.opentelemetry.server.collector.Instrumentation

public class Instrumentation extends Object
A simple class with helper methods for OpenTelemetry embedded collectors own telemetry.
  • Constructor Details

    • Instrumentation

      public Instrumentation()
  • Method Details

    • startNewSpan

      public io.opentelemetry.api.trace.Span startNewSpan(String spanName)
      Start a new span.
      Parameters:
      spanName - the name of the new span
      Returns:
      the created span
    • startNewSpan

      public io.opentelemetry.api.trace.Span startNewSpan(io.opentelemetry.api.trace.Span parent, String spanName)
      Start a new child span.
      Parameters:
      parent - the parent span
      spanName - the new span name
      Returns:
      the created span
    • withSpan

      public io.opentelemetry.context.Scope withSpan(io.opentelemetry.api.trace.Span span)
      Set the given span as current.
      Parameters:
      span - the span
      Returns:
      the scope to be used
    • wrapInSpan

      public <T> CompletableFuture<T> wrapInSpan(CompletableFuture<T> future, Supplier<io.opentelemetry.api.trace.Span> newSpanSupplier)
      Wraps a CompletableFuture so that when it completes a span will be ended accordingly.
      Type Parameters:
      T - the return type of the future
      Parameters:
      future - the future
      newSpanSupplier - supplier of the span to wrap into
      Returns:
      a new future to be used instead
    • addErrorEvent

      public void addErrorEvent(io.opentelemetry.api.trace.Span span, Throwable t)
      Add an error to a span.
      Parameters:
      span - the span
      t - the exception that caused the error
    • addErrorEvent

      public void addErrorEvent(io.opentelemetry.api.trace.Span span, String errorMsg)
      Add an error to a span.
      Parameters:
      span - the span
      errorMsg - a text error message
    • addEvent

      public void addEvent(io.opentelemetry.context.Context ctx, String message)
      Add an event to the current span in the given context.
      Parameters:
      ctx - the context
      message - the event message
    • addErrorEvent

      public void addErrorEvent(io.opentelemetry.context.Context ctx, Throwable t)
      Add an error to the current span in the given context.
      Parameters:
      ctx - the context
      t - the exception that caused the error
    • endCurrentSpan

      public void endCurrentSpan(io.opentelemetry.context.Context ctx, Throwable t)
      End the current span in a given context with an error.
      Parameters:
      ctx - the context
      t - the exception that caused the error
    • newLongCounter

      public io.opentelemetry.api.metrics.LongCounter newLongCounter(String name, String unit, String description)
      Create a new long counter metric.
      Parameters:
      name - the metric name
      unit - the unit of measure
      description - the metric description
      Returns:
      a new long counter
    • newLongUpDownCounter

      public io.opentelemetry.api.metrics.LongUpDownCounter newLongUpDownCounter(String name, String unit, String description)
      Create a new long UpDown counter metric.
      Parameters:
      name - the metric name
      unit - the unit of measure
      description - the metric description
      Returns:
      a new UpDown counter metric
    • newLongGauge

      public io.opentelemetry.api.metrics.ObservableLongGauge newLongGauge(String name, String unit, String description, Consumer<io.opentelemetry.api.metrics.ObservableLongMeasurement> measurementCallback)
      Create a new long gauge metric with a callback.
      Parameters:
      name - the metric name
      unit - the unit of measure
      description - the metric description
      measurementCallback - the callback to get values from
      Returns:
      the new long gauge
    • newLongHistogram

      public io.opentelemetry.api.metrics.LongHistogram newLongHistogram(String name, String unit, String description, List<Long> bucketBoundaries)
      Create a new long histogram metric.
      Parameters:
      name - the metric name
      unit - the unit of measure
      description - the metric description
      bucketBoundaries - the desired histogram buckets
      Returns:
      the new long histogram metric