// Copyright 2025 Envoy Project Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// 
//     http://www.apache.org/licenses/LICENSE-2.0
// 
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

syntax = "proto3";

package envoy.extensions.stat_sinks.open_telemetry.v3;

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

import "google/protobuf/wrappers.proto";

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

option java_package = "io.envoyproxy.envoy.extensions.stat_sinks.open_telemetry.v3";
option java_outer_classname = "OpenTelemetryProto";
option java_multiple_files = true;
option go_package = "github.com/envoyproxy/go-control-plane/envoy/extensions/stat_sinks/open_telemetry/v3;open_telemetryv3";
option (udpa.annotations.file_status).package_version_status = ACTIVE;

// [#protodoc-title: Open Telemetry Stats Sink]
// Stats configuration proto schema for ``envoy.stat_sinks.open_telemetry`` sink.
// [#extension: envoy.stat_sinks.open_telemetry]

// [#next-free-field: 8]
message SinkConfig {
  oneof protocol_specifier {
    option (validate.required) = true;

    // The upstream gRPC cluster that implements the OTLP/gRPC collector.
    config.core.v3.GrpcService grpc_service = 1 [(validate.rules).message = {required: true}];
  }

  // Attributes to be associated with the resource in the OTLP message.
  // [#extension-category: envoy.tracers.opentelemetry.resource_detectors]
  repeated config.core.v3.TypedExtensionConfig resource_detectors = 7;

  // If set to true, counters will be emitted as deltas, and the OTLP message will have
  // ``AGGREGATION_TEMPORALITY_DELTA`` set as AggregationTemporality.
  bool report_counters_as_deltas = 2;

  // If set to true, histograms will be emitted as deltas, and the OTLP message will have
  // ``AGGREGATION_TEMPORALITY_DELTA`` set as AggregationTemporality.
  bool report_histograms_as_deltas = 3;

  // If set to true, metrics will have their tags emitted as OTLP attributes, which may
  // contain values used by the tag extractor or additional tags added during stats creation.
  // Otherwise, no attributes will be associated with the export message. Default value is true.
  google.protobuf.BoolValue emit_tags_as_attributes = 4;

  // If set to true, metric names will be represented as the tag extracted name instead
  // of the full metric name. Default value is true.
  google.protobuf.BoolValue use_tag_extracted_name = 5;

  // If set, emitted stats names will be prepended with a prefix, so full stat name will be
  // <prefix>.<stats_name>. For example, if the stat name is "foo.bar" and prefix is
  // "pre", the full stat name will be "pre.foo.bar". If this field is not set, there is no
  // prefix added. According to the example, the full stat name will remain "foo.bar".
  string prefix = 6;
}
