All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.opentelemetry.exporter.otlp.internal.OtlpSpanExporterComponentProvider Maven / Gradle / Ivy

There is a newer version: 1.44.1
Show newest version
/*
 * Copyright The OpenTelemetry Authors
 * SPDX-License-Identifier: Apache-2.0
 */

package io.opentelemetry.exporter.otlp.internal;

import static io.opentelemetry.exporter.otlp.internal.OtlpConfigUtil.DATA_TYPE_TRACES;
import static io.opentelemetry.exporter.otlp.internal.OtlpConfigUtil.PROTOCOL_GRPC;
import static io.opentelemetry.exporter.otlp.internal.OtlpConfigUtil.PROTOCOL_HTTP_PROTOBUF;

import io.opentelemetry.exporter.otlp.http.trace.OtlpHttpSpanExporter;
import io.opentelemetry.exporter.otlp.http.trace.OtlpHttpSpanExporterBuilder;
import io.opentelemetry.exporter.otlp.trace.OtlpGrpcSpanExporter;
import io.opentelemetry.exporter.otlp.trace.OtlpGrpcSpanExporterBuilder;
import io.opentelemetry.sdk.autoconfigure.spi.ConfigurationException;
import io.opentelemetry.sdk.autoconfigure.spi.internal.ComponentProvider;
import io.opentelemetry.sdk.autoconfigure.spi.internal.StructuredConfigProperties;
import io.opentelemetry.sdk.trace.export.SpanExporter;

/**
 * File configuration SPI implementation for {@link OtlpHttpSpanExporter} and {@link
 * OtlpGrpcSpanExporter}.
 *
 * 

This class is internal and is hence not for public use. Its APIs are unstable and can change * at any time. */ public class OtlpSpanExporterComponentProvider implements ComponentProvider { @Override public Class getType() { return SpanExporter.class; } @Override public String getName() { return "otlp"; } @Override public SpanExporter create(StructuredConfigProperties config) { String protocol = OtlpConfigUtil.getStructuredConfigOtlpProtocol(config); if (protocol.equals(PROTOCOL_HTTP_PROTOBUF)) { OtlpHttpSpanExporterBuilder builder = httpBuilder(); OtlpConfigUtil.configureOtlpExporterBuilder( DATA_TYPE_TRACES, config, builder::setEndpoint, builder::addHeader, builder::setCompression, builder::setTimeout, builder::setTrustedCertificates, builder::setClientTls, builder::setRetryPolicy, builder::setMemoryMode); return builder.build(); } else if (protocol.equals(PROTOCOL_GRPC)) { OtlpGrpcSpanExporterBuilder builder = grpcBuilder(); OtlpConfigUtil.configureOtlpExporterBuilder( DATA_TYPE_TRACES, config, builder::setEndpoint, builder::addHeader, builder::setCompression, builder::setTimeout, builder::setTrustedCertificates, builder::setClientTls, builder::setRetryPolicy, builder::setMemoryMode); return builder.build(); } throw new ConfigurationException("Unsupported OTLP metrics protocol: " + protocol); } // Visible for testing OtlpHttpSpanExporterBuilder httpBuilder() { return OtlpHttpSpanExporter.builder(); } // Visible for testing OtlpGrpcSpanExporterBuilder grpcBuilder() { return OtlpGrpcSpanExporter.builder(); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy