Skip to content

Commit

Permalink
fix(zpages): use tonic based generated files. (#1214)
Browse files Browse the repository at this point in the history
* fix(zpages): use tonic based generated files.

The reason zpages cannot compile after #1202 is prost backed grpcio compiler no longer allow us to add `serde` macros onto the types. Thus, instead of using grpcio types, use tonic types in zpages fixes it.

* add changelog
  • Loading branch information
TommyCpp authored Aug 23, 2023
1 parent 6f7f8bb commit 3c560d9
Show file tree
Hide file tree
Showing 18 changed files with 82 additions and 21 deletions.
1 change: 1 addition & 0 deletions opentelemetry-proto/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
### Added

- Implement tonic metrics proto transformations (#1184)
- Move proto for zPage to tonic [#1214](https://github.com/open-telemetry/opentelemetry-rust/pull/1214)

### Changed

Expand Down
2 changes: 1 addition & 1 deletion opentelemetry-proto/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ tonic = { version = "0.9.0", default-features = false, optional = true, features
prost = { version = "0.11.0", optional = true }
opentelemetry_api = { version = "0.20", default-features = false, path = "../opentelemetry-api" }
opentelemetry_sdk = { version = "0.20", default-features = false, path = "../opentelemetry-sdk" }
serde = { version = "1.0", optional = true }
serde = { version = "1.0", optional = true, features = ["serde_derive"] }

[dev-dependencies]
grpcio-compiler = { version = "0.12.1", default-features = false, features = ["prost-codec"] }
Expand Down
16 changes: 8 additions & 8 deletions opentelemetry-proto/src/proto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,14 @@ pub mod tonic {
pub mod v1;
}

/// Generated types used in zpages.
#[cfg(feature = "zpages")]
#[path = ""]
pub mod tracez {
#[path = "opentelemetry.proto.tracez.v1.rs"]
pub mod v1;
}

pub use crate::transform::common::tonic::Attributes;
}

Expand Down Expand Up @@ -134,13 +142,5 @@ pub mod grpcio {
pub mod v1;
}

/// Generated types used in zpages.
#[cfg(feature = "zpages")]
#[path = ""]
pub mod tracez {
#[path = "opentelemetry.proto.tracez.v1.rs"]
pub mod v1;
}

pub use crate::transform::common::grpcio::Attributes;
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ExportLogsServiceRequest {
Expand All @@ -11,6 +12,7 @@ pub struct ExportLogsServiceRequest {
super::super::super::logs::v1::ResourceLogs,
>,
}
#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ExportLogsServiceResponse {
Expand All @@ -32,6 +34,7 @@ pub struct ExportLogsServiceResponse {
#[prost(message, optional, tag = "1")]
pub partial_success: ::core::option::Option<ExportLogsPartialSuccess>,
}
#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ExportLogsPartialSuccess {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ExportMetricsServiceRequest {
Expand All @@ -11,6 +12,7 @@ pub struct ExportMetricsServiceRequest {
super::super::super::metrics::v1::ResourceMetrics,
>,
}
#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ExportMetricsServiceResponse {
Expand All @@ -32,6 +34,7 @@ pub struct ExportMetricsServiceResponse {
#[prost(message, optional, tag = "1")]
pub partial_success: ::core::option::Option<ExportMetricsPartialSuccess>,
}
#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ExportMetricsPartialSuccess {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ExportTraceServiceRequest {
Expand All @@ -11,6 +12,7 @@ pub struct ExportTraceServiceRequest {
super::super::super::trace::v1::ResourceSpans,
>,
}
#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ExportTraceServiceResponse {
Expand All @@ -32,6 +34,7 @@ pub struct ExportTraceServiceResponse {
#[prost(message, optional, tag = "1")]
pub partial_success: ::core::option::Option<ExportTracePartialSuccess>,
}
#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ExportTracePartialSuccess {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/// AnyValue is used to represent any type of attribute value. AnyValue may contain a
/// primitive value such as a string or integer or it may contain an arbitrary nested
/// object containing arrays, key-value lists and primitives.
#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct AnyValue {
Expand All @@ -13,6 +14,7 @@ pub struct AnyValue {
pub mod any_value {
/// The value is one of the listed fields. It is valid for all values to be unspecified
/// in which case this AnyValue is considered to be "empty".
#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum Value {
Expand All @@ -34,6 +36,7 @@ pub mod any_value {
}
/// ArrayValue is a list of AnyValue messages. We need ArrayValue as a message
/// since oneof in AnyValue does not allow repeated fields.
#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ArrayValue {
Expand All @@ -46,6 +49,7 @@ pub struct ArrayValue {
/// a list of KeyValue messages (e.g. in Span) we use `repeated KeyValue` directly to
/// avoid unnecessary extra wrapping (which slows down the protocol). The 2 approaches
/// are semantically equivalent.
#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct KeyValueList {
Expand All @@ -58,6 +62,7 @@ pub struct KeyValueList {
}
/// KeyValue is a key-value pair that is used to store Span attributes, Link
/// attributes, etc.
#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct KeyValue {
Expand All @@ -68,6 +73,7 @@ pub struct KeyValue {
}
/// InstrumentationScope is a message representing the instrumentation scope information
/// such as the fully qualified name and version.
#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct InstrumentationScope {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
///
/// When new fields are added into this message, the OTLP request MUST be updated
/// as well.
#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct LogsData {
Expand All @@ -20,6 +21,7 @@ pub struct LogsData {
pub resource_logs: ::prost::alloc::vec::Vec<ResourceLogs>,
}
/// A collection of ScopeLogs from a Resource.
#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ResourceLogs {
Expand All @@ -36,6 +38,7 @@ pub struct ResourceLogs {
pub schema_url: ::prost::alloc::string::String,
}
/// A collection of Logs produced by a Scope.
#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ScopeLogs {
Expand All @@ -53,6 +56,7 @@ pub struct ScopeLogs {
}
/// A log record according to OpenTelemetry Log Data Model:
/// <https://github.com/open-telemetry/oteps/blob/main/text/logs/0097-log-data-model.md>
#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct LogRecord {
Expand Down Expand Up @@ -134,6 +138,7 @@ pub struct LogRecord {
pub span_id: ::prost::alloc::vec::Vec<u8>,
}
/// Possible values for LogRecord.SeverityNumber.
#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum SeverityNumber {
Expand Down Expand Up @@ -236,6 +241,7 @@ impl SeverityNumber {
///
/// (logRecord.flags & LOG_RECORD_FLAGS_TRACE_FLAGS_MASK)
///
#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum LogRecordFlags {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
///
/// When new fields are added into this message, the OTLP request MUST be updated
/// as well.
#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct MetricsData {
Expand All @@ -20,6 +21,7 @@ pub struct MetricsData {
pub resource_metrics: ::prost::alloc::vec::Vec<ResourceMetrics>,
}
/// A collection of ScopeMetrics from a Resource.
#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ResourceMetrics {
Expand All @@ -36,6 +38,7 @@ pub struct ResourceMetrics {
pub schema_url: ::prost::alloc::string::String,
}
/// A collection of Metrics produced by an Scope.
#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ScopeMetrics {
Expand Down Expand Up @@ -136,6 +139,7 @@ pub struct ScopeMetrics {
/// to support correct rate calculation. Although it may be omitted
/// when the start time is truly unknown, setting StartTimeUnixNano is
/// strongly encouraged.
#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Metric {
Expand All @@ -160,6 +164,7 @@ pub mod metric {
/// Data determines the aggregation type (if any) of the metric, what is the
/// reported value type for the data points, as well as the relatationship to
/// the time interval over which they are reported.
#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum Data {
Expand All @@ -184,6 +189,7 @@ pub mod metric {
/// aggregation, regardless of aggregation temporalities. Therefore,
/// AggregationTemporality is not included. Consequently, this also means
/// "StartTimeUnixNano" is ignored for all data points.
#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Gauge {
Expand All @@ -192,6 +198,7 @@ pub struct Gauge {
}
/// Sum represents the type of a scalar metric that is calculated as a sum of all
/// reported measurements over a time interval.
#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Sum {
Expand All @@ -207,6 +214,7 @@ pub struct Sum {
}
/// Histogram represents the type of a metric that is calculated by aggregating
/// as a Histogram of all reported measurements over a time interval.
#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Histogram {
Expand All @@ -219,6 +227,7 @@ pub struct Histogram {
}
/// ExponentialHistogram represents the type of a metric that is calculated by aggregating
/// as a ExponentialHistogram of all reported double measurements over a time interval.
#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ExponentialHistogram {
Expand All @@ -235,6 +244,7 @@ pub struct ExponentialHistogram {
/// data type. These data points cannot always be merged in a meaningful way.
/// While they can be useful in some applications, histogram data points are
/// recommended for new applications.
#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Summary {
Expand All @@ -243,6 +253,7 @@ pub struct Summary {
}
/// NumberDataPoint is a single data point in a timeseries that describes the
/// time-varying scalar value of a metric.
#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct NumberDataPoint {
Expand Down Expand Up @@ -282,6 +293,7 @@ pub struct NumberDataPoint {
pub mod number_data_point {
/// The value itself. A point is considered invalid when one of the recognized
/// value fields is not present inside this oneof.
#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum Value {
Expand All @@ -301,6 +313,7 @@ pub mod number_data_point {
/// If the histogram does not contain the distribution of values, then both
/// "explicit_bounds" and "bucket_counts" must be omitted and only "count" and
/// "sum" are known.
#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct HistogramDataPoint {
Expand Down Expand Up @@ -382,6 +395,7 @@ pub struct HistogramDataPoint {
/// summary statistics for a population of values, it may optionally contain the
/// distribution of those values across a set of buckets.
///
#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ExponentialHistogramDataPoint {
Expand Down Expand Up @@ -479,6 +493,7 @@ pub struct ExponentialHistogramDataPoint {
pub mod exponential_histogram_data_point {
/// Buckets are a set of bucket counts, encoded in a contiguous array
/// of counts.
#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Buckets {
Expand All @@ -502,6 +517,7 @@ pub mod exponential_histogram_data_point {
}
/// SummaryDataPoint is a single data point in a timeseries that describes the
/// time-varying values of a Summary metric.
#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct SummaryDataPoint {
Expand Down Expand Up @@ -556,6 +572,7 @@ pub mod summary_data_point {
///
/// See the following issue for more context:
/// <https://github.com/open-telemetry/opentelemetry-proto/issues/125>
#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ValueAtQuantile {
Expand All @@ -574,6 +591,7 @@ pub mod summary_data_point {
/// Exemplars also hold information about the environment when the measurement
/// was recorded, for example the span and trace ID of the active span when the
/// exemplar was recorded.
#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Exemplar {
Expand Down Expand Up @@ -611,6 +629,7 @@ pub mod exemplar {
/// The value of the measurement that was recorded. An exemplar is
/// considered invalid when one of the recognized value fields is not present
/// inside this oneof.
#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum Value {
Expand All @@ -623,6 +642,7 @@ pub mod exemplar {
/// AggregationTemporality defines how a metric aggregator reports aggregated
/// values. It describes how those values relate to the time interval over
/// which they are aggregated.
#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum AggregationTemporality {
Expand Down Expand Up @@ -719,6 +739,7 @@ impl AggregationTemporality {
///
/// (point.flags & DATA_POINT_FLAGS_NO_RECORDED_VALUE_MASK) == DATA_POINT_FLAGS_NO_RECORDED_VALUE_MASK
///
#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum DataPointFlags {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/// Resource information.
#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))]
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Resource {
Expand Down
Loading

0 comments on commit 3c560d9

Please sign in to comment.