Skip to content

Commit 27b19b6

Browse files
authored
Update OTLP proto version to 1.1.0 (#1482)
1 parent c7ab26b commit 27b19b6

10 files changed

+197
-9
lines changed

opentelemetry-proto/CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
### Added
66

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

910
## v0.4.0
1011

opentelemetry-proto/src/proto/grpcio/opentelemetry.proto.logs.v1.rs

+11-3
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ pub struct ResourceLogs {
3030
/// A list of ScopeLogs that originate from a resource.
3131
#[prost(message, repeated, tag = "2")]
3232
pub scope_logs: ::prost::alloc::vec::Vec<ScopeLogs>,
33+
/// The Schema URL, if known. This is the identifier of the Schema that the resource data
34+
/// is recorded in. To learn more about Schema URL see
35+
/// <https://opentelemetry.io/docs/specs/otel/schemas/#schema-url>
3336
/// This schema_url applies to the data in the "resource" field. It does not apply
3437
/// to the data in the "scope_logs" field which have their own schema_url field.
3538
#[prost(string, tag = "3")]
@@ -47,6 +50,9 @@ pub struct ScopeLogs {
4750
/// A list of log records.
4851
#[prost(message, repeated, tag = "2")]
4952
pub log_records: ::prost::alloc::vec::Vec<LogRecord>,
53+
/// The Schema URL, if known. This is the identifier of the Schema that the log data
54+
/// is recorded in. To learn more about Schema URL see
55+
/// <https://opentelemetry.io/docs/specs/otel/schemas/#schema-url>
5056
/// This schema_url applies to all logs in the "logs" field.
5157
#[prost(string, tag = "3")]
5258
pub schema_url: ::prost::alloc::string::String,
@@ -230,9 +236,11 @@ impl SeverityNumber {
230236
}
231237
}
232238
}
233-
/// LogRecordFlags is defined as a protobuf 'uint32' type and is to be used as
234-
/// bit-fields. Each non-zero value defined in this enum is a bit-mask.
235-
/// To extract the bit-field, for example, use an expression like:
239+
/// LogRecordFlags represents constants used to interpret the
240+
/// LogRecord.flags field, which is protobuf 'fixed32' type and is to
241+
/// be used as bit-fields. Each non-zero value defined in this enum is
242+
/// a bit-mask. To extract the bit-field, for example, use an
243+
/// expression like:
236244
///
237245
/// (logRecord.flags & LOG_RECORD_FLAGS_TRACE_FLAGS_MASK)
238246
///

opentelemetry-proto/src/proto/grpcio/opentelemetry.proto.metrics.v1.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ pub struct ResourceMetrics {
3030
/// A list of metrics that originate from a resource.
3131
#[prost(message, repeated, tag = "2")]
3232
pub scope_metrics: ::prost::alloc::vec::Vec<ScopeMetrics>,
33+
/// The Schema URL, if known. This is the identifier of the Schema that the resource data
34+
/// is recorded in. To learn more about Schema URL see
35+
/// <https://opentelemetry.io/docs/specs/otel/schemas/#schema-url>
3336
/// This schema_url applies to the data in the "resource" field. It does not apply
3437
/// to the data in the "scope_metrics" field which have their own schema_url field.
3538
#[prost(string, tag = "3")]
@@ -47,6 +50,9 @@ pub struct ScopeMetrics {
4750
/// A list of metrics that originate from an instrumentation library.
4851
#[prost(message, repeated, tag = "2")]
4952
pub metrics: ::prost::alloc::vec::Vec<Metric>,
53+
/// The Schema URL, if known. This is the identifier of the Schema that the metric data
54+
/// is recorded in. To learn more about Schema URL see
55+
/// <https://opentelemetry.io/docs/specs/otel/schemas/#schema-url>
5056
/// This schema_url applies to all metrics in the "metrics" field.
5157
#[prost(string, tag = "3")]
5258
pub schema_url: ::prost::alloc::string::String,
@@ -139,7 +145,7 @@ pub struct ScopeMetrics {
139145
#[allow(clippy::derive_partial_eq_without_eq)]
140146
#[derive(Clone, PartialEq, ::prost::Message)]
141147
pub struct Metric {
142-
/// name of the metric, including its DNS name prefix. It must be unique.
148+
/// name of the metric.
143149
#[prost(string, tag = "1")]
144150
pub name: ::prost::alloc::string::String,
145151
/// description of the metric, which can be used in documentation.

opentelemetry-proto/src/proto/grpcio/opentelemetry.proto.trace.v1.rs

+75
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ pub struct ResourceSpans {
3030
/// A list of ScopeSpans that originate from a resource.
3131
#[prost(message, repeated, tag = "2")]
3232
pub scope_spans: ::prost::alloc::vec::Vec<ScopeSpans>,
33+
/// The Schema URL, if known. This is the identifier of the Schema that the resource data
34+
/// is recorded in. To learn more about Schema URL see
35+
/// <https://opentelemetry.io/docs/specs/otel/schemas/#schema-url>
3336
/// This schema_url applies to the data in the "resource" field. It does not apply
3437
/// to the data in the "scope_spans" field which have their own schema_url field.
3538
#[prost(string, tag = "3")]
@@ -47,6 +50,9 @@ pub struct ScopeSpans {
4750
/// A list of Spans that originate from an instrumentation scope.
4851
#[prost(message, repeated, tag = "2")]
4952
pub spans: ::prost::alloc::vec::Vec<Span>,
53+
/// The Schema URL, if known. This is the identifier of the Schema that the span data
54+
/// is recorded in. To learn more about Schema URL see
55+
/// <https://opentelemetry.io/docs/specs/otel/schemas/#schema-url>
5056
/// This schema_url applies to all spans and span events in the "spans" field.
5157
#[prost(string, tag = "3")]
5258
pub schema_url: ::prost::alloc::string::String,
@@ -82,6 +88,22 @@ pub struct Span {
8288
/// field must be empty. The ID is an 8-byte array.
8389
#[prost(bytes = "vec", tag = "4")]
8490
pub parent_span_id: ::prost::alloc::vec::Vec<u8>,
91+
/// Flags, a bit field. 8 least significant bits are the trace
92+
/// flags as defined in W3C Trace Context specification. Readers
93+
/// MUST not assume that 24 most significant bits will be zero.
94+
/// To read the 8-bit W3C trace flag, use `flags & SPAN_FLAGS_TRACE_FLAGS_MASK`.
95+
///
96+
/// When creating span messages, if the message is logically forwarded from another source
97+
/// with an equivalent flags fields (i.e., usually another OTLP span message), the field SHOULD
98+
/// be copied as-is. If creating from a source that does not have an equivalent flags field
99+
/// (such as a runtime representation of an OpenTelemetry span), the high 24 bits MUST
100+
/// be set to zero.
101+
///
102+
/// \[Optional\].
103+
///
104+
/// See <https://www.w3.org/TR/trace-context-2/#trace-flags> for the flag definitions.
105+
#[prost(fixed32, tag = "16")]
106+
pub flags: u32,
85107
/// A description of the span's operation.
86108
///
87109
/// For example, the name can be a qualified method name or a file name
@@ -209,6 +231,16 @@ pub mod span {
209231
/// then no attributes were dropped.
210232
#[prost(uint32, tag = "5")]
211233
pub dropped_attributes_count: u32,
234+
/// Flags, a bit field. 8 least significant bits are the trace
235+
/// flags as defined in W3C Trace Context specification. Readers
236+
/// MUST not assume that 24 most significant bits will be zero.
237+
/// When creating new spans, the most-significant 24-bits MUST be
238+
/// zero. To read the 8-bit W3C trace flag (use flags &
239+
/// SPAN_FLAGS_TRACE_FLAGS_MASK). \[Optional\].
240+
///
241+
/// See <https://www.w3.org/TR/trace-context-2/#trace-flags> for the flag definitions.
242+
#[prost(fixed32, tag = "6")]
243+
pub flags: u32,
212244
}
213245
/// SpanKind is the type of span. Can be used to specify additional relationships between spans
214246
/// in addition to a parent/child relationship.
@@ -335,3 +367,46 @@ pub mod status {
335367
}
336368
}
337369
}
370+
/// SpanFlags represents constants used to interpret the
371+
/// Span.flags field, which is protobuf 'fixed32' type and is to
372+
/// be used as bit-fields. Each non-zero value defined in this enum is
373+
/// a bit-mask. To extract the bit-field, for example, use an
374+
/// expression like:
375+
///
376+
/// (span.flags & SPAN_FLAGS_TRACE_FLAGS_MASK)
377+
///
378+
/// See <https://www.w3.org/TR/trace-context-2/#trace-flags> for the flag definitions.
379+
///
380+
/// Note that Span flags were introduced in version 1.1 of the
381+
/// OpenTelemetry protocol. Older Span producers do not set this
382+
/// field, consequently consumers should not rely on the absence of a
383+
/// particular flag bit to indicate the presence of a particular feature.
384+
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
385+
#[repr(i32)]
386+
pub enum SpanFlags {
387+
/// The zero value for the enum. Should not be used for comparisons.
388+
/// Instead use bitwise "and" with the appropriate mask as shown above.
389+
DoNotUse = 0,
390+
/// Bits 0-7 are used for trace flags.
391+
TraceFlagsMask = 255,
392+
}
393+
impl SpanFlags {
394+
/// String value of the enum field names used in the ProtoBuf definition.
395+
///
396+
/// The values are not transformed in any way and thus are considered stable
397+
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
398+
pub fn as_str_name(&self) -> &'static str {
399+
match self {
400+
SpanFlags::DoNotUse => "SPAN_FLAGS_DO_NOT_USE",
401+
SpanFlags::TraceFlagsMask => "SPAN_FLAGS_TRACE_FLAGS_MASK",
402+
}
403+
}
404+
/// Creates an enum from field names used in the ProtoBuf definition.
405+
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
406+
match value {
407+
"SPAN_FLAGS_DO_NOT_USE" => Some(Self::DoNotUse),
408+
"SPAN_FLAGS_TRACE_FLAGS_MASK" => Some(Self::TraceFlagsMask),
409+
_ => None,
410+
}
411+
}
412+
}

opentelemetry-proto/src/proto/tonic/opentelemetry.proto.logs.v1.rs

+11-3
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ pub struct ResourceLogs {
3636
/// A list of ScopeLogs that originate from a resource.
3737
#[prost(message, repeated, tag = "2")]
3838
pub scope_logs: ::prost::alloc::vec::Vec<ScopeLogs>,
39+
/// The Schema URL, if known. This is the identifier of the Schema that the resource data
40+
/// is recorded in. To learn more about Schema URL see
41+
/// <https://opentelemetry.io/docs/specs/otel/schemas/#schema-url>
3942
/// This schema_url applies to the data in the "resource" field. It does not apply
4043
/// to the data in the "scope_logs" field which have their own schema_url field.
4144
#[prost(string, tag = "3")]
@@ -56,6 +59,9 @@ pub struct ScopeLogs {
5659
/// A list of log records.
5760
#[prost(message, repeated, tag = "2")]
5861
pub log_records: ::prost::alloc::vec::Vec<LogRecord>,
62+
/// The Schema URL, if known. This is the identifier of the Schema that the log data
63+
/// is recorded in. To learn more about Schema URL see
64+
/// <https://opentelemetry.io/docs/specs/otel/schemas/#schema-url>
5965
/// This schema_url applies to all logs in the "logs" field.
6066
#[prost(string, tag = "3")]
6167
pub schema_url: ::prost::alloc::string::String,
@@ -245,9 +251,11 @@ impl SeverityNumber {
245251
}
246252
}
247253
}
248-
/// LogRecordFlags is defined as a protobuf 'uint32' type and is to be used as
249-
/// bit-fields. Each non-zero value defined in this enum is a bit-mask.
250-
/// To extract the bit-field, for example, use an expression like:
254+
/// LogRecordFlags represents constants used to interpret the
255+
/// LogRecord.flags field, which is protobuf 'fixed32' type and is to
256+
/// be used as bit-fields. Each non-zero value defined in this enum is
257+
/// a bit-mask. To extract the bit-field, for example, use an
258+
/// expression like:
251259
///
252260
/// (logRecord.flags & LOG_RECORD_FLAGS_TRACE_FLAGS_MASK)
253261
///

opentelemetry-proto/src/proto/tonic/opentelemetry.proto.metrics.v1.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ pub struct ResourceMetrics {
3636
/// A list of metrics that originate from a resource.
3737
#[prost(message, repeated, tag = "2")]
3838
pub scope_metrics: ::prost::alloc::vec::Vec<ScopeMetrics>,
39+
/// The Schema URL, if known. This is the identifier of the Schema that the resource data
40+
/// is recorded in. To learn more about Schema URL see
41+
/// <https://opentelemetry.io/docs/specs/otel/schemas/#schema-url>
3942
/// This schema_url applies to the data in the "resource" field. It does not apply
4043
/// to the data in the "scope_metrics" field which have their own schema_url field.
4144
#[prost(string, tag = "3")]
@@ -56,6 +59,9 @@ pub struct ScopeMetrics {
5659
/// A list of metrics that originate from an instrumentation library.
5760
#[prost(message, repeated, tag = "2")]
5861
pub metrics: ::prost::alloc::vec::Vec<Metric>,
62+
/// The Schema URL, if known. This is the identifier of the Schema that the metric data
63+
/// is recorded in. To learn more about Schema URL see
64+
/// <https://opentelemetry.io/docs/specs/otel/schemas/#schema-url>
5965
/// This schema_url applies to all metrics in the "metrics" field.
6066
#[prost(string, tag = "3")]
6167
pub schema_url: ::prost::alloc::string::String,
@@ -151,7 +157,7 @@ pub struct ScopeMetrics {
151157
#[allow(clippy::derive_partial_eq_without_eq)]
152158
#[derive(Clone, PartialEq, ::prost::Message)]
153159
pub struct Metric {
154-
/// name of the metric, including its DNS name prefix. It must be unique.
160+
/// name of the metric.
155161
#[prost(string, tag = "1")]
156162
pub name: ::prost::alloc::string::String,
157163
/// description of the metric, which can be used in documentation.

opentelemetry-proto/src/proto/tonic/opentelemetry.proto.trace.v1.rs

+78
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ pub struct ResourceSpans {
3737
/// A list of ScopeSpans that originate from a resource.
3838
#[prost(message, repeated, tag = "2")]
3939
pub scope_spans: ::prost::alloc::vec::Vec<ScopeSpans>,
40+
/// The Schema URL, if known. This is the identifier of the Schema that the resource data
41+
/// is recorded in. To learn more about Schema URL see
42+
/// <https://opentelemetry.io/docs/specs/otel/schemas/#schema-url>
4043
/// This schema_url applies to the data in the "resource" field. It does not apply
4144
/// to the data in the "scope_spans" field which have their own schema_url field.
4245
#[prost(string, tag = "3")]
@@ -58,6 +61,9 @@ pub struct ScopeSpans {
5861
/// A list of Spans that originate from an instrumentation scope.
5962
#[prost(message, repeated, tag = "2")]
6063
pub spans: ::prost::alloc::vec::Vec<Span>,
64+
/// The Schema URL, if known. This is the identifier of the Schema that the span data
65+
/// is recorded in. To learn more about Schema URL see
66+
/// <https://opentelemetry.io/docs/specs/otel/schemas/#schema-url>
6167
/// This schema_url applies to all spans and span events in the "spans" field.
6268
#[prost(string, tag = "3")]
6369
pub schema_url: ::prost::alloc::string::String,
@@ -118,6 +124,22 @@ pub struct Span {
118124
)
119125
)]
120126
pub parent_span_id: ::prost::alloc::vec::Vec<u8>,
127+
/// Flags, a bit field. 8 least significant bits are the trace
128+
/// flags as defined in W3C Trace Context specification. Readers
129+
/// MUST not assume that 24 most significant bits will be zero.
130+
/// To read the 8-bit W3C trace flag, use `flags & SPAN_FLAGS_TRACE_FLAGS_MASK`.
131+
///
132+
/// When creating span messages, if the message is logically forwarded from another source
133+
/// with an equivalent flags fields (i.e., usually another OTLP span message), the field SHOULD
134+
/// be copied as-is. If creating from a source that does not have an equivalent flags field
135+
/// (such as a runtime representation of an OpenTelemetry span), the high 24 bits MUST
136+
/// be set to zero.
137+
///
138+
/// \[Optional\].
139+
///
140+
/// See <https://www.w3.org/TR/trace-context-2/#trace-flags> for the flag definitions.
141+
#[prost(fixed32, tag = "16")]
142+
pub flags: u32,
121143
/// A description of the span's operation.
122144
///
123145
/// For example, the name can be a qualified method name or a file name
@@ -253,6 +275,16 @@ pub mod span {
253275
/// then no attributes were dropped.
254276
#[prost(uint32, tag = "5")]
255277
pub dropped_attributes_count: u32,
278+
/// Flags, a bit field. 8 least significant bits are the trace
279+
/// flags as defined in W3C Trace Context specification. Readers
280+
/// MUST not assume that 24 most significant bits will be zero.
281+
/// When creating new spans, the most-significant 24-bits MUST be
282+
/// zero. To read the 8-bit W3C trace flag (use flags &
283+
/// SPAN_FLAGS_TRACE_FLAGS_MASK). \[Optional\].
284+
///
285+
/// See <https://www.w3.org/TR/trace-context-2/#trace-flags> for the flag definitions.
286+
#[prost(fixed32, tag = "6")]
287+
pub flags: u32,
256288
}
257289
/// SpanKind is the type of span. Can be used to specify additional relationships between spans
258290
/// in addition to a parent/child relationship.
@@ -388,3 +420,49 @@ pub mod status {
388420
}
389421
}
390422
}
423+
/// SpanFlags represents constants used to interpret the
424+
/// Span.flags field, which is protobuf 'fixed32' type and is to
425+
/// be used as bit-fields. Each non-zero value defined in this enum is
426+
/// a bit-mask. To extract the bit-field, for example, use an
427+
/// expression like:
428+
///
429+
/// (span.flags & SPAN_FLAGS_TRACE_FLAGS_MASK)
430+
///
431+
/// See <https://www.w3.org/TR/trace-context-2/#trace-flags> for the flag definitions.
432+
///
433+
/// Note that Span flags were introduced in version 1.1 of the
434+
/// OpenTelemetry protocol. Older Span producers do not set this
435+
/// field, consequently consumers should not rely on the absence of a
436+
/// particular flag bit to indicate the presence of a particular feature.
437+
#[cfg_attr(feature = "with-schemars", derive(schemars::JsonSchema))]
438+
#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))]
439+
#[cfg_attr(feature = "with-serde", serde(rename_all = "camelCase"))]
440+
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
441+
#[repr(i32)]
442+
pub enum SpanFlags {
443+
/// The zero value for the enum. Should not be used for comparisons.
444+
/// Instead use bitwise "and" with the appropriate mask as shown above.
445+
DoNotUse = 0,
446+
/// Bits 0-7 are used for trace flags.
447+
TraceFlagsMask = 255,
448+
}
449+
impl SpanFlags {
450+
/// String value of the enum field names used in the ProtoBuf definition.
451+
///
452+
/// The values are not transformed in any way and thus are considered stable
453+
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
454+
pub fn as_str_name(&self) -> &'static str {
455+
match self {
456+
SpanFlags::DoNotUse => "SPAN_FLAGS_DO_NOT_USE",
457+
SpanFlags::TraceFlagsMask => "SPAN_FLAGS_TRACE_FLAGS_MASK",
458+
}
459+
}
460+
/// Creates an enum from field names used in the ProtoBuf definition.
461+
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
462+
match value {
463+
"SPAN_FLAGS_DO_NOT_USE" => Some(Self::DoNotUse),
464+
"SPAN_FLAGS_TRACE_FLAGS_MASK" => Some(Self::TraceFlagsMask),
465+
_ => None,
466+
}
467+
}
468+
}

opentelemetry-proto/src/transform/trace.rs

+4
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ pub mod tonic {
4040
trace_state: link.span_context.trace_state().header(),
4141
attributes: Attributes::from(link.attributes).0,
4242
dropped_attributes_count: link.dropped_attributes_count,
43+
flags: link.span_context.trace_flags().to_u8() as u32,
4344
}
4445
}
4546
}
@@ -76,6 +77,7 @@ pub mod tonic {
7677
vec![]
7778
}
7879
},
80+
flags: source_span.span_context.trace_flags().to_u8() as u32,
7981
name: source_span.name.into_owned(),
8082
kind: span_kind as i32,
8183
start_time_unix_nano: to_nanos(source_span.start_time),
@@ -151,6 +153,7 @@ pub mod grpcio {
151153
trace_state: link.span_context.trace_state().header(),
152154
attributes: Attributes::from(link.attributes).0,
153155
dropped_attributes_count: link.dropped_attributes_count,
156+
flags: link.span_context.trace_flags().to_u8() as u32,
154157
}
155158
}
156159
}
@@ -187,6 +190,7 @@ pub mod grpcio {
187190
vec![]
188191
}
189192
},
193+
flags: source_span.span_context.trace_flags().to_u8() as u32,
190194
name: source_span.name.into_owned(),
191195
kind: span_kind as i32,
192196
start_time_unix_nano: to_nanos(source_span.start_time),

0 commit comments

Comments
 (0)