syntax = "proto3";

package envoy.extensions.stat_sinks.dynamic_modules.v3;

import "envoy/extensions/dynamic_modules/v3/dynamic_modules.proto";

import "google/protobuf/any.proto";

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

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

// [#protodoc-title: Dynamic Modules Stats Sink]
// [#extension: envoy.stat_sinks.dynamic_modules]

// Configuration for the Dynamic Modules Stats Sink. This sink allows loading shared object
// files via ``dlopen`` to implement custom stats sink behavior.
//
// A module can be loaded by multiple stat sinks. It is loaded only once and shared
// across multiple sink instances.
//
// The stats sink receives periodic metric snapshots of counters, gauges, and text readouts,
// and is also called synchronously when histogram observations are recorded.
message DynamicModuleStatsSink {
  // Specifies the shared-object level configuration. This field is required.
  envoy.extensions.dynamic_modules.v3.DynamicModuleConfig dynamic_module_config = 1
      [(validate.rules).message = {required: true}];

  // The name for this sink configuration. If not specified, defaults to an empty string.
  //
  // This can be used to distinguish between different sink implementations inside a dynamic
  // module. When Envoy receives this configuration, it passes the ``sink_name`` to the dynamic
  // module's sink config init function together with the ``sink_config``.
  string sink_name = 2;

  // The configuration for the sink chosen by ``sink_name``. If not specified, an empty
  // configuration is passed to the module.
  //
  // ``google.protobuf.Struct`` is serialized as JSON before passing it to the module.
  // ``google.protobuf.BytesValue`` and ``google.protobuf.StringValue`` are passed directly
  // without the wrapper.
  //
  // .. code-block:: yaml
  //
  //  # Passing a JSON struct configuration
  //  sink_config:
  //    "@type": "type.googleapis.com/google.protobuf.Struct"
  //    value:
  //      endpoint: "metrics.example.com:9125"
  //      prefix: "envoy"
  //
  //  # Passing a simple string configuration
  //  sink_config:
  //    "@type": "type.googleapis.com/google.protobuf.StringValue"
  //    value: "metrics.example.com:9125"
  //
  google.protobuf.Any sink_config = 3;
}
