syntax = "proto3";

package envoy.config.trace.v3;

import "envoy/config/core/v3/extension.proto";
import "envoy/config/core/v3/grpc_service.proto";
import "envoy/config/core/v3/http_service.proto";

import "google/protobuf/wrappers.proto";

import "udpa/annotations/migrate.proto";
import "udpa/annotations/status.proto";

option java_package = "io.envoyproxy.envoy.config.trace.v3";
option java_outer_classname = "OpentelemetryProto";
option java_multiple_files = true;
option go_package = "github.com/envoyproxy/go-control-plane/envoy/config/trace/v3;tracev3";
option (udpa.annotations.file_status).package_version_status = ACTIVE;

// [#protodoc-title: OpenTelemetry tracer]

// Configuration for the OpenTelemetry tracer.
//  [#extension: envoy.tracers.opentelemetry]
// [#next-free-field: 9]
message OpenTelemetryConfig {
  // The upstream gRPC cluster that will receive OTLP traces.
  // Note that the tracer drops traces if the server does not read data fast enough.
  // This field can be left empty to disable reporting traces to the gRPC service.
  // Only one of ``grpc_service``, ``http_service`` may be used.
  core.v3.GrpcService grpc_service = 1
      [(udpa.annotations.field_migrate).oneof_promotion = "otlp_exporter"];

  // The upstream HTTP cluster that will receive OTLP traces.
  // This field can be left empty to disable reporting traces to the HTTP service.
  // Only one of ``grpc_service``, ``http_service`` may be used.
  //
  // .. note::
  //
  //   The ``request_headers_to_add`` property in the OTLP HTTP exporter service supports
  //   substitution formatters. The formatters cannot access any HTTP or connection properties, but
  //   can load content such as environment variables or files or secrets.
  core.v3.HttpService http_service = 3
      [(udpa.annotations.field_migrate).oneof_promotion = "otlp_exporter"];

  // The name for the service. This will be populated in the ResourceSpan Resource attributes.
  // If it is not provided, it will default to "unknown_service:envoy".
  string service_name = 2;

  // An ordered list of resource detectors
  // [#extension-category: envoy.tracers.opentelemetry.resource_detectors]
  repeated core.v3.TypedExtensionConfig resource_detectors = 4;

  // Specifies the sampler to be used by the OpenTelemetry tracer.
  // The configured sampler implements the Sampler interface defined by the OpenTelemetry specification.
  // This field can be left empty. In this case, the default Envoy sampling decision is used.
  //
  // See: `OpenTelemetry sampler specification <https://opentelemetry.io/docs/specs/otel/trace/sdk/#sampler>`_
  // [#extension-category: envoy.tracers.opentelemetry.samplers]
  core.v3.TypedExtensionConfig sampler = 5;

  // Envoy caches the span in memory when the OpenTelemetry backend service is temporarily unavailable.
  // This field specifies the maximum number of spans that can be cached. If not specified, the
  // default is 1024.
  google.protobuf.UInt32Value max_cache_size = 6;

  // Specifies whether to set the telemetry SDK resource attributes.
  // The following attributes will be set:
  //
  // - telemetry.sdk.language
  // - telemetry.sdk.name
  // - telemetry.sdk.version
  //
  // If not specified, the default is to set these attributes.
  google.protobuf.BoolValue set_telemetry_sdk_resource_attributes = 7;

  // Specifies whether to set the ``service.name`` resource attribute.
  // If not specified, the default is to set this attribute.
  google.protobuf.BoolValue set_service_name_resource_attribute = 8;
}
