Class OtlpGrpcMetricExporter

  • All Implemented Interfaces:
    io.opentelemetry.sdk.metrics.export.MetricExporter

    @ThreadSafe
    public final class OtlpGrpcMetricExporter
    extends java.lang.Object
    implements io.opentelemetry.sdk.metrics.export.MetricExporter
    Exports metrics using OTLP via gRPC, using OpenTelemetry's protobuf model.

    Configuration options for OtlpGrpcMetricExporter can be read from system properties, environment variables, or Properties objects.

    For system properties and Properties objects, OtlpGrpcMetricExporter will look for the following names:

    • otel.exporter.otlp.metric.timeout: to set the max waiting time allowed to send each span batch.
    • otel.exporter.otlp.metric.endpoint: to set the endpoint to connect to.
    • otel.exporter.otlp.metric.insecure: whether to enable client transport security for the connection.
    • otel.exporter.otlp.metric.headers: the headers associated with the requests.

    For environment variables, OtlpGrpcMetricExporter will look for the following names:

    • OTEL_EXPORTER_OTLP_METRIC_TIMEOUT: to set the max waiting time allowed to send each span batch.
    • OTEL_EXPORTER_OTLP_METRIC_ENDPOINT: to set the endpoint to connect to.
    • OTEL_EXPORTER_OTLP_METRIC_INSECURE: whether to enable client transport security for the connection.
    • OTEL_EXPORTER_OTLP_METRIC_HEADERS: the headers associated with the requests.

    In both cases, if a property is missing, the name without "span" is used to resolve the value.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  OtlpGrpcMetricExporter.Builder
      Builder utility for this exporter.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static OtlpGrpcMetricExporter.Builder builder()
      Returns a new builder instance for this exporter.
      io.opentelemetry.sdk.common.CompletableResultCode export​(java.util.Collection<io.opentelemetry.sdk.metrics.data.MetricData> metrics)
      Submits all the given metrics in a single batch to the OpenTelemetry collector.
      io.opentelemetry.sdk.common.CompletableResultCode flush()
      The OTLP exporter does not batch metrics, so this method will immediately return with success.
      static OtlpGrpcMetricExporter getDefault()
      Returns a new OtlpGrpcMetricExporter reading the configuration values from the environment and from system properties.
      void shutdown()
      Initiates an orderly shutdown in which preexisting calls continue but new calls are immediately cancelled.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • DEFAULT_ENDPOINT

        public static final java.lang.String DEFAULT_ENDPOINT
        See Also:
        Constant Field Values
      • DEFAULT_DEADLINE_MS

        public static final long DEFAULT_DEADLINE_MS
    • Method Detail

      • export

        public io.opentelemetry.sdk.common.CompletableResultCode export​(java.util.Collection<io.opentelemetry.sdk.metrics.data.MetricData> metrics)
        Submits all the given metrics in a single batch to the OpenTelemetry collector.
        Specified by:
        export in interface io.opentelemetry.sdk.metrics.export.MetricExporter
        Parameters:
        metrics - the list of Metrics to be exported.
        Returns:
        the result of the operation
      • flush

        public io.opentelemetry.sdk.common.CompletableResultCode flush()
        The OTLP exporter does not batch metrics, so this method will immediately return with success.
        Specified by:
        flush in interface io.opentelemetry.sdk.metrics.export.MetricExporter
        Returns:
        always Success
      • builder

        public static OtlpGrpcMetricExporter.Builder builder()
        Returns a new builder instance for this exporter.
        Returns:
        a new builder instance for this exporter.
      • getDefault

        public static OtlpGrpcMetricExporter getDefault()
        Returns a new OtlpGrpcMetricExporter reading the configuration values from the environment and from system properties. System properties override values defined in the environment. If a configuration value is missing, it uses the default value.
        Returns:
        a new OtlpGrpcMetricExporter instance.
      • shutdown

        public void shutdown()
        Initiates an orderly shutdown in which preexisting calls continue but new calls are immediately cancelled. The channel is forcefully closed after a timeout.
        Specified by:
        shutdown in interface io.opentelemetry.sdk.metrics.export.MetricExporter