From b746e276b48c4e25db80c4105c2c7a081c8b43ce Mon Sep 17 00:00:00 2001 From: "data-plane-api(Azure Pipelines)" Date: Tue, 25 Apr 2023 20:12:09 +0000 Subject: [PATCH] stat_sinks: add OpenTelemetry stats sink (#26620) Signed-off-by: ohadvano Mirrored from https://github.com/envoyproxy/envoy @ a6d46b6ac4750720eec9a49abe701f0df9bf8e0a --- BUILD | 1 + bazel/external_proto_deps.bzl | 3 ++ bazel/repositories.bzl | 20 ++++++++ .../stat_sinks/open_telemetry/v3/BUILD | 12 +++++ .../open_telemetry/v3/open_telemetry.proto | 47 +++++++++++++++++++ versioning/BUILD | 1 + 6 files changed, 84 insertions(+) create mode 100644 envoy/extensions/stat_sinks/open_telemetry/v3/BUILD create mode 100644 envoy/extensions/stat_sinks/open_telemetry/v3/open_telemetry.proto diff --git a/BUILD b/BUILD index d4c2a4f5..6129177e 100644 --- a/BUILD +++ b/BUILD @@ -286,6 +286,7 @@ proto_library( "//envoy/extensions/retry/host/previous_hosts/v3:pkg", "//envoy/extensions/retry/priority/previous_priorities/v3:pkg", "//envoy/extensions/stat_sinks/graphite_statsd/v3:pkg", + "//envoy/extensions/stat_sinks/open_telemetry/v3:pkg", "//envoy/extensions/stat_sinks/wasm/v3:pkg", "//envoy/extensions/transport_sockets/alts/v3:pkg", "//envoy/extensions/transport_sockets/http_11_proxy/v3:pkg", diff --git a/bazel/external_proto_deps.bzl b/bazel/external_proto_deps.bzl index 3bcc2b02..bea4868d 100644 --- a/bazel/external_proto_deps.bzl +++ b/bazel/external_proto_deps.bzl @@ -34,6 +34,7 @@ EXTERNAL_PROTO_GO_BAZEL_DEP_MAP = { "@opencensus_proto//opencensus/proto/trace/v1:trace_config_proto": "@opencensus_proto//opencensus/proto/trace/v1:trace_and_config_proto_go", "@opentelemetry_proto//:trace": "@opentelemetry_proto//:trace_go_proto", "@opentelemetry_proto//:logs": "@opentelemetry_proto//:logs_go_proto", + "@opentelemetry_proto//:metrics": "@opentelemetry_proto//:metrics_go_proto", "@opentelemetry_proto//:common": "@opentelemetry_proto//:common_go_proto", } @@ -45,6 +46,7 @@ EXTERNAL_PROTO_CC_BAZEL_DEP_MAP = { "@opencensus_proto//opencensus/proto/trace/v1:trace_config_proto": "@opencensus_proto//opencensus/proto/trace/v1:trace_config_proto_cc", "@opentelemetry_proto//:trace": "@opentelemetry_proto//:trace_cc_proto", "@opentelemetry_proto//:logs": "@opentelemetry_proto//:logs_cc_proto", + "@opentelemetry_proto//:metrics": "@opentelemetry_proto//:metrics_cc_proto", "@opentelemetry_proto//:common": "@opentelemetry_proto//:common_cc_proto", } @@ -56,5 +58,6 @@ EXTERNAL_PROTO_PY_BAZEL_DEP_MAP = { "@opencensus_proto//opencensus/proto/trace/v1:trace_config_proto": "@opencensus_proto//opencensus/proto/trace/v1:trace_config_proto_py", "@opentelemetry_proto//:trace": "@opentelemetry_proto//:trace_py_proto", "@opentelemetry_proto//:logs": "@opentelemetry_proto//:logs_py_proto", + "@opentelemetry_proto//:metrics": "@opentelemetry_proto//:metrics_py_proto", "@opentelemetry_proto//:common": "@opentelemetry_proto//:common_py_proto", } diff --git a/bazel/repositories.bzl b/bazel/repositories.bzl index 69b97a4c..b23156e2 100644 --- a/bazel/repositories.bzl +++ b/bazel/repositories.bzl @@ -163,6 +163,26 @@ go_proto_library( visibility = ["//visibility:public"], ) +api_cc_py_proto_library( + name = "metrics", + srcs = [ + "opentelemetry/proto/collector/metrics/v1/metrics_service.proto", + "opentelemetry/proto/metrics/v1/metrics.proto", + ], + deps = [ + "//:common", + "//:resource", + ], + visibility = ["//visibility:public"], +) + +go_proto_library( + name = "metrics_go_proto", + importpath = "go.opentelemetry.io/proto/otlp/metrics/v1", + proto = ":metrics", + visibility = ["//visibility:public"], +) + api_cc_py_proto_library( name = "trace", srcs = [ diff --git a/envoy/extensions/stat_sinks/open_telemetry/v3/BUILD b/envoy/extensions/stat_sinks/open_telemetry/v3/BUILD new file mode 100644 index 00000000..1c1a6f6b --- /dev/null +++ b/envoy/extensions/stat_sinks/open_telemetry/v3/BUILD @@ -0,0 +1,12 @@ +# DO NOT EDIT. This file is generated by tools/proto_format/proto_sync.py. + +load("@envoy_api//bazel:api_build_system.bzl", "api_proto_package") + +licenses(["notice"]) # Apache 2 + +api_proto_package( + deps = [ + "//envoy/config/core/v3:pkg", + "@com_github_cncf_udpa//udpa/annotations:pkg", + ], +) diff --git a/envoy/extensions/stat_sinks/open_telemetry/v3/open_telemetry.proto b/envoy/extensions/stat_sinks/open_telemetry/v3/open_telemetry.proto new file mode 100644 index 00000000..3e2b84c8 --- /dev/null +++ b/envoy/extensions/stat_sinks/open_telemetry/v3/open_telemetry.proto @@ -0,0 +1,47 @@ +syntax = "proto3"; + +package envoy.extensions.stat_sinks.open_telemetry.v3; + +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: 6] +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}]; + } + + // 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; +} diff --git a/versioning/BUILD b/versioning/BUILD index c31f8ea1..3ccb627e 100644 --- a/versioning/BUILD +++ b/versioning/BUILD @@ -225,6 +225,7 @@ proto_library( "//envoy/extensions/retry/host/previous_hosts/v3:pkg", "//envoy/extensions/retry/priority/previous_priorities/v3:pkg", "//envoy/extensions/stat_sinks/graphite_statsd/v3:pkg", + "//envoy/extensions/stat_sinks/open_telemetry/v3:pkg", "//envoy/extensions/stat_sinks/wasm/v3:pkg", "//envoy/extensions/transport_sockets/alts/v3:pkg", "//envoy/extensions/transport_sockets/http_11_proxy/v3:pkg",