Skip to content

Commit

Permalink
Update OTLP proto version to 1.1.0 (#1482)
Browse files Browse the repository at this point in the history
  • Loading branch information
lalitb authored Jan 25, 2024
1 parent c7ab26b commit 27b19b6
Show file tree
Hide file tree
Showing 10 changed files with 197 additions and 9 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

- Add `schemars::JsonSchema` trait support with `with-schemars` feature (#1419)
- Update protobuf definitions to v1.1.0 (#1154)

## v0.4.0

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ pub struct ResourceLogs {
/// A list of ScopeLogs that originate from a resource.
#[prost(message, repeated, tag = "2")]
pub scope_logs: ::prost::alloc::vec::Vec<ScopeLogs>,
/// The Schema URL, if known. This is the identifier of the Schema that the resource data
/// is recorded in. To learn more about Schema URL see
/// <https://opentelemetry.io/docs/specs/otel/schemas/#schema-url>
/// This schema_url applies to the data in the "resource" field. It does not apply
/// to the data in the "scope_logs" field which have their own schema_url field.
#[prost(string, tag = "3")]
Expand All @@ -47,6 +50,9 @@ pub struct ScopeLogs {
/// A list of log records.
#[prost(message, repeated, tag = "2")]
pub log_records: ::prost::alloc::vec::Vec<LogRecord>,
/// The Schema URL, if known. This is the identifier of the Schema that the log data
/// is recorded in. To learn more about Schema URL see
/// <https://opentelemetry.io/docs/specs/otel/schemas/#schema-url>
/// This schema_url applies to all logs in the "logs" field.
#[prost(string, tag = "3")]
pub schema_url: ::prost::alloc::string::String,
Expand Down Expand Up @@ -230,9 +236,11 @@ impl SeverityNumber {
}
}
}
/// LogRecordFlags is defined as a protobuf 'uint32' type and is to be used as
/// bit-fields. Each non-zero value defined in this enum is a bit-mask.
/// To extract the bit-field, for example, use an expression like:
/// LogRecordFlags represents constants used to interpret the
/// LogRecord.flags field, which is protobuf 'fixed32' type and is to
/// be used as bit-fields. Each non-zero value defined in this enum is
/// a bit-mask. To extract the bit-field, for example, use an
/// expression like:
///
/// (logRecord.flags & LOG_RECORD_FLAGS_TRACE_FLAGS_MASK)
///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ pub struct ResourceMetrics {
/// A list of metrics that originate from a resource.
#[prost(message, repeated, tag = "2")]
pub scope_metrics: ::prost::alloc::vec::Vec<ScopeMetrics>,
/// The Schema URL, if known. This is the identifier of the Schema that the resource data
/// is recorded in. To learn more about Schema URL see
/// <https://opentelemetry.io/docs/specs/otel/schemas/#schema-url>
/// This schema_url applies to the data in the "resource" field. It does not apply
/// to the data in the "scope_metrics" field which have their own schema_url field.
#[prost(string, tag = "3")]
Expand All @@ -47,6 +50,9 @@ pub struct ScopeMetrics {
/// A list of metrics that originate from an instrumentation library.
#[prost(message, repeated, tag = "2")]
pub metrics: ::prost::alloc::vec::Vec<Metric>,
/// The Schema URL, if known. This is the identifier of the Schema that the metric data
/// is recorded in. To learn more about Schema URL see
/// <https://opentelemetry.io/docs/specs/otel/schemas/#schema-url>
/// This schema_url applies to all metrics in the "metrics" field.
#[prost(string, tag = "3")]
pub schema_url: ::prost::alloc::string::String,
Expand Down Expand Up @@ -139,7 +145,7 @@ pub struct ScopeMetrics {
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Metric {
/// name of the metric, including its DNS name prefix. It must be unique.
/// name of the metric.
#[prost(string, tag = "1")]
pub name: ::prost::alloc::string::String,
/// description of the metric, which can be used in documentation.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ pub struct ResourceSpans {
/// A list of ScopeSpans that originate from a resource.
#[prost(message, repeated, tag = "2")]
pub scope_spans: ::prost::alloc::vec::Vec<ScopeSpans>,
/// The Schema URL, if known. This is the identifier of the Schema that the resource data
/// is recorded in. To learn more about Schema URL see
/// <https://opentelemetry.io/docs/specs/otel/schemas/#schema-url>
/// This schema_url applies to the data in the "resource" field. It does not apply
/// to the data in the "scope_spans" field which have their own schema_url field.
#[prost(string, tag = "3")]
Expand All @@ -47,6 +50,9 @@ pub struct ScopeSpans {
/// A list of Spans that originate from an instrumentation scope.
#[prost(message, repeated, tag = "2")]
pub spans: ::prost::alloc::vec::Vec<Span>,
/// The Schema URL, if known. This is the identifier of the Schema that the span data
/// is recorded in. To learn more about Schema URL see
/// <https://opentelemetry.io/docs/specs/otel/schemas/#schema-url>
/// This schema_url applies to all spans and span events in the "spans" field.
#[prost(string, tag = "3")]
pub schema_url: ::prost::alloc::string::String,
Expand Down Expand Up @@ -82,6 +88,22 @@ pub struct Span {
/// field must be empty. The ID is an 8-byte array.
#[prost(bytes = "vec", tag = "4")]
pub parent_span_id: ::prost::alloc::vec::Vec<u8>,
/// Flags, a bit field. 8 least significant bits are the trace
/// flags as defined in W3C Trace Context specification. Readers
/// MUST not assume that 24 most significant bits will be zero.
/// To read the 8-bit W3C trace flag, use `flags & SPAN_FLAGS_TRACE_FLAGS_MASK`.
///
/// When creating span messages, if the message is logically forwarded from another source
/// with an equivalent flags fields (i.e., usually another OTLP span message), the field SHOULD
/// be copied as-is. If creating from a source that does not have an equivalent flags field
/// (such as a runtime representation of an OpenTelemetry span), the high 24 bits MUST
/// be set to zero.
///
/// \[Optional\].
///
/// See <https://www.w3.org/TR/trace-context-2/#trace-flags> for the flag definitions.
#[prost(fixed32, tag = "16")]
pub flags: u32,
/// A description of the span's operation.
///
/// For example, the name can be a qualified method name or a file name
Expand Down Expand Up @@ -209,6 +231,16 @@ pub mod span {
/// then no attributes were dropped.
#[prost(uint32, tag = "5")]
pub dropped_attributes_count: u32,
/// Flags, a bit field. 8 least significant bits are the trace
/// flags as defined in W3C Trace Context specification. Readers
/// MUST not assume that 24 most significant bits will be zero.
/// When creating new spans, the most-significant 24-bits MUST be
/// zero. To read the 8-bit W3C trace flag (use flags &
/// SPAN_FLAGS_TRACE_FLAGS_MASK). \[Optional\].
///
/// See <https://www.w3.org/TR/trace-context-2/#trace-flags> for the flag definitions.
#[prost(fixed32, tag = "6")]
pub flags: u32,
}
/// SpanKind is the type of span. Can be used to specify additional relationships between spans
/// in addition to a parent/child relationship.
Expand Down Expand Up @@ -335,3 +367,46 @@ pub mod status {
}
}
}
/// SpanFlags represents constants used to interpret the
/// Span.flags field, which is protobuf 'fixed32' type and is to
/// be used as bit-fields. Each non-zero value defined in this enum is
/// a bit-mask. To extract the bit-field, for example, use an
/// expression like:
///
/// (span.flags & SPAN_FLAGS_TRACE_FLAGS_MASK)
///
/// See <https://www.w3.org/TR/trace-context-2/#trace-flags> for the flag definitions.
///
/// Note that Span flags were introduced in version 1.1 of the
/// OpenTelemetry protocol. Older Span producers do not set this
/// field, consequently consumers should not rely on the absence of a
/// particular flag bit to indicate the presence of a particular feature.
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum SpanFlags {
/// The zero value for the enum. Should not be used for comparisons.
/// Instead use bitwise "and" with the appropriate mask as shown above.
DoNotUse = 0,
/// Bits 0-7 are used for trace flags.
TraceFlagsMask = 255,
}
impl SpanFlags {
/// String value of the enum field names used in the ProtoBuf definition.
///
/// The values are not transformed in any way and thus are considered stable
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
pub fn as_str_name(&self) -> &'static str {
match self {
SpanFlags::DoNotUse => "SPAN_FLAGS_DO_NOT_USE",
SpanFlags::TraceFlagsMask => "SPAN_FLAGS_TRACE_FLAGS_MASK",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"SPAN_FLAGS_DO_NOT_USE" => Some(Self::DoNotUse),
"SPAN_FLAGS_TRACE_FLAGS_MASK" => Some(Self::TraceFlagsMask),
_ => None,
}
}
}
14 changes: 11 additions & 3 deletions opentelemetry-proto/src/proto/tonic/opentelemetry.proto.logs.v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ pub struct ResourceLogs {
/// A list of ScopeLogs that originate from a resource.
#[prost(message, repeated, tag = "2")]
pub scope_logs: ::prost::alloc::vec::Vec<ScopeLogs>,
/// The Schema URL, if known. This is the identifier of the Schema that the resource data
/// is recorded in. To learn more about Schema URL see
/// <https://opentelemetry.io/docs/specs/otel/schemas/#schema-url>
/// This schema_url applies to the data in the "resource" field. It does not apply
/// to the data in the "scope_logs" field which have their own schema_url field.
#[prost(string, tag = "3")]
Expand All @@ -56,6 +59,9 @@ pub struct ScopeLogs {
/// A list of log records.
#[prost(message, repeated, tag = "2")]
pub log_records: ::prost::alloc::vec::Vec<LogRecord>,
/// The Schema URL, if known. This is the identifier of the Schema that the log data
/// is recorded in. To learn more about Schema URL see
/// <https://opentelemetry.io/docs/specs/otel/schemas/#schema-url>
/// This schema_url applies to all logs in the "logs" field.
#[prost(string, tag = "3")]
pub schema_url: ::prost::alloc::string::String,
Expand Down Expand Up @@ -245,9 +251,11 @@ impl SeverityNumber {
}
}
}
/// LogRecordFlags is defined as a protobuf 'uint32' type and is to be used as
/// bit-fields. Each non-zero value defined in this enum is a bit-mask.
/// To extract the bit-field, for example, use an expression like:
/// LogRecordFlags represents constants used to interpret the
/// LogRecord.flags field, which is protobuf 'fixed32' type and is to
/// be used as bit-fields. Each non-zero value defined in this enum is
/// a bit-mask. To extract the bit-field, for example, use an
/// expression like:
///
/// (logRecord.flags & LOG_RECORD_FLAGS_TRACE_FLAGS_MASK)
///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ pub struct ResourceMetrics {
/// A list of metrics that originate from a resource.
#[prost(message, repeated, tag = "2")]
pub scope_metrics: ::prost::alloc::vec::Vec<ScopeMetrics>,
/// The Schema URL, if known. This is the identifier of the Schema that the resource data
/// is recorded in. To learn more about Schema URL see
/// <https://opentelemetry.io/docs/specs/otel/schemas/#schema-url>
/// This schema_url applies to the data in the "resource" field. It does not apply
/// to the data in the "scope_metrics" field which have their own schema_url field.
#[prost(string, tag = "3")]
Expand All @@ -56,6 +59,9 @@ pub struct ScopeMetrics {
/// A list of metrics that originate from an instrumentation library.
#[prost(message, repeated, tag = "2")]
pub metrics: ::prost::alloc::vec::Vec<Metric>,
/// The Schema URL, if known. This is the identifier of the Schema that the metric data
/// is recorded in. To learn more about Schema URL see
/// <https://opentelemetry.io/docs/specs/otel/schemas/#schema-url>
/// This schema_url applies to all metrics in the "metrics" field.
#[prost(string, tag = "3")]
pub schema_url: ::prost::alloc::string::String,
Expand Down Expand Up @@ -151,7 +157,7 @@ pub struct ScopeMetrics {
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Metric {
/// name of the metric, including its DNS name prefix. It must be unique.
/// name of the metric.
#[prost(string, tag = "1")]
pub name: ::prost::alloc::string::String,
/// description of the metric, which can be used in documentation.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ pub struct ResourceSpans {
/// A list of ScopeSpans that originate from a resource.
#[prost(message, repeated, tag = "2")]
pub scope_spans: ::prost::alloc::vec::Vec<ScopeSpans>,
/// The Schema URL, if known. This is the identifier of the Schema that the resource data
/// is recorded in. To learn more about Schema URL see
/// <https://opentelemetry.io/docs/specs/otel/schemas/#schema-url>
/// This schema_url applies to the data in the "resource" field. It does not apply
/// to the data in the "scope_spans" field which have their own schema_url field.
#[prost(string, tag = "3")]
Expand All @@ -58,6 +61,9 @@ pub struct ScopeSpans {
/// A list of Spans that originate from an instrumentation scope.
#[prost(message, repeated, tag = "2")]
pub spans: ::prost::alloc::vec::Vec<Span>,
/// The Schema URL, if known. This is the identifier of the Schema that the span data
/// is recorded in. To learn more about Schema URL see
/// <https://opentelemetry.io/docs/specs/otel/schemas/#schema-url>
/// This schema_url applies to all spans and span events in the "spans" field.
#[prost(string, tag = "3")]
pub schema_url: ::prost::alloc::string::String,
Expand Down Expand Up @@ -118,6 +124,22 @@ pub struct Span {
)
)]
pub parent_span_id: ::prost::alloc::vec::Vec<u8>,
/// Flags, a bit field. 8 least significant bits are the trace
/// flags as defined in W3C Trace Context specification. Readers
/// MUST not assume that 24 most significant bits will be zero.
/// To read the 8-bit W3C trace flag, use `flags & SPAN_FLAGS_TRACE_FLAGS_MASK`.
///
/// When creating span messages, if the message is logically forwarded from another source
/// with an equivalent flags fields (i.e., usually another OTLP span message), the field SHOULD
/// be copied as-is. If creating from a source that does not have an equivalent flags field
/// (such as a runtime representation of an OpenTelemetry span), the high 24 bits MUST
/// be set to zero.
///
/// \[Optional\].
///
/// See <https://www.w3.org/TR/trace-context-2/#trace-flags> for the flag definitions.
#[prost(fixed32, tag = "16")]
pub flags: u32,
/// A description of the span's operation.
///
/// For example, the name can be a qualified method name or a file name
Expand Down Expand Up @@ -253,6 +275,16 @@ pub mod span {
/// then no attributes were dropped.
#[prost(uint32, tag = "5")]
pub dropped_attributes_count: u32,
/// Flags, a bit field. 8 least significant bits are the trace
/// flags as defined in W3C Trace Context specification. Readers
/// MUST not assume that 24 most significant bits will be zero.
/// When creating new spans, the most-significant 24-bits MUST be
/// zero. To read the 8-bit W3C trace flag (use flags &
/// SPAN_FLAGS_TRACE_FLAGS_MASK). \[Optional\].
///
/// See <https://www.w3.org/TR/trace-context-2/#trace-flags> for the flag definitions.
#[prost(fixed32, tag = "6")]
pub flags: u32,
}
/// SpanKind is the type of span. Can be used to specify additional relationships between spans
/// in addition to a parent/child relationship.
Expand Down Expand Up @@ -388,3 +420,49 @@ pub mod status {
}
}
}
/// SpanFlags represents constants used to interpret the
/// Span.flags field, which is protobuf 'fixed32' type and is to
/// be used as bit-fields. Each non-zero value defined in this enum is
/// a bit-mask. To extract the bit-field, for example, use an
/// expression like:
///
/// (span.flags & SPAN_FLAGS_TRACE_FLAGS_MASK)
///
/// See <https://www.w3.org/TR/trace-context-2/#trace-flags> for the flag definitions.
///
/// Note that Span flags were introduced in version 1.1 of the
/// OpenTelemetry protocol. Older Span producers do not set this
/// field, consequently consumers should not rely on the absence of a
/// particular flag bit to indicate the presence of a particular feature.
#[cfg_attr(feature = "with-schemars", derive(schemars::JsonSchema))]
#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "with-serde", serde(rename_all = "camelCase"))]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum SpanFlags {
/// The zero value for the enum. Should not be used for comparisons.
/// Instead use bitwise "and" with the appropriate mask as shown above.
DoNotUse = 0,
/// Bits 0-7 are used for trace flags.
TraceFlagsMask = 255,
}
impl SpanFlags {
/// String value of the enum field names used in the ProtoBuf definition.
///
/// The values are not transformed in any way and thus are considered stable
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
pub fn as_str_name(&self) -> &'static str {
match self {
SpanFlags::DoNotUse => "SPAN_FLAGS_DO_NOT_USE",
SpanFlags::TraceFlagsMask => "SPAN_FLAGS_TRACE_FLAGS_MASK",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"SPAN_FLAGS_DO_NOT_USE" => Some(Self::DoNotUse),
"SPAN_FLAGS_TRACE_FLAGS_MASK" => Some(Self::TraceFlagsMask),
_ => None,
}
}
}
4 changes: 4 additions & 0 deletions opentelemetry-proto/src/transform/trace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ pub mod tonic {
trace_state: link.span_context.trace_state().header(),
attributes: Attributes::from(link.attributes).0,
dropped_attributes_count: link.dropped_attributes_count,
flags: link.span_context.trace_flags().to_u8() as u32,
}
}
}
Expand Down Expand Up @@ -76,6 +77,7 @@ pub mod tonic {
vec![]
}
},
flags: source_span.span_context.trace_flags().to_u8() as u32,
name: source_span.name.into_owned(),
kind: span_kind as i32,
start_time_unix_nano: to_nanos(source_span.start_time),
Expand Down Expand Up @@ -151,6 +153,7 @@ pub mod grpcio {
trace_state: link.span_context.trace_state().header(),
attributes: Attributes::from(link.attributes).0,
dropped_attributes_count: link.dropped_attributes_count,
flags: link.span_context.trace_flags().to_u8() as u32,
}
}
}
Expand Down Expand Up @@ -187,6 +190,7 @@ pub mod grpcio {
vec![]
}
},
flags: source_span.span_context.trace_flags().to_u8() as u32,
name: source_span.name.into_owned(),
kind: span_kind as i32,
start_time_unix_nano: to_nanos(source_span.start_time),
Expand Down
Loading

0 comments on commit 27b19b6

Please sign in to comment.