Skip to content

Commit

Permalink
Update serialization format for LogRecord fields. (#1771)
Browse files Browse the repository at this point in the history
Co-authored-by: Zhongyang Wu <[email protected]>
Co-authored-by: Cijo Thomas <[email protected]>
  • Loading branch information
3 people authored May 15, 2024
1 parent 1733da5 commit 10f99bf
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
28 changes: 28 additions & 0 deletions opentelemetry-proto/src/proto/tonic/opentelemetry.proto.logs.v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,13 @@ pub struct LogRecord {
/// Value is UNIX Epoch time in nanoseconds since 00:00:00 UTC on 1 January 1970.
/// Value of 0 indicates unknown or missing timestamp.
#[prost(fixed64, tag = "1")]
#[cfg_attr(
feature = "with-serde",
serde(
serialize_with = "crate::proto::serializers::serialize_u64_to_string",
deserialize_with = "crate::proto::serializers::deserialize_string_to_u64"
)
)]
pub time_unix_nano: u64,
/// Time when the event was observed by the collection system.
/// For events that originate in OpenTelemetry (e.g. using OpenTelemetry Logging SDK)
Expand All @@ -96,6 +103,13 @@ pub struct LogRecord {
/// Value is UNIX Epoch time in nanoseconds since 00:00:00 UTC on 1 January 1970.
/// Value of 0 indicates unknown or missing timestamp.
#[prost(fixed64, tag = "11")]
#[cfg_attr(
feature = "with-serde",
serde(
serialize_with = "crate::proto::serializers::serialize_u64_to_string",
deserialize_with = "crate::proto::serializers::deserialize_string_to_u64"
)
)]
pub observed_time_unix_nano: u64,
/// Numerical value of the severity, normalized to values described in Log Data Model.
/// \[Optional\].
Expand Down Expand Up @@ -136,6 +150,13 @@ pub struct LogRecord {
/// - the field is not present,
/// - the field contains an invalid value.
#[prost(bytes = "vec", tag = "9")]
#[cfg_attr(
feature = "with-serde",
serde(
serialize_with = "crate::proto::serializers::serialize_to_hex_string",
deserialize_with = "crate::proto::serializers::deserialize_from_hex_string"
)
)]
pub trace_id: ::prost::alloc::vec::Vec<u8>,
/// A unique identifier for a span within a trace, assigned when the span
/// is created. The ID is an 8-byte array. An ID with all zeroes OR of length
Expand All @@ -150,6 +171,13 @@ pub struct LogRecord {
/// - the field is not present,
/// - the field contains an invalid value.
#[prost(bytes = "vec", tag = "10")]
#[cfg_attr(
feature = "with-serde",
serde(
serialize_with = "crate::proto::serializers::serialize_to_hex_string",
deserialize_with = "crate::proto::serializers::deserialize_from_hex_string"
)
)]
pub span_id: ::prost::alloc::vec::Vec<u8>,
}
/// Possible values for LogRecord.SeverityNumber.
Expand Down
4 changes: 4 additions & 0 deletions opentelemetry-proto/tests/grpc_build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ fn build_tonic() {
"trace.v1.Span.trace_id",
"trace.v1.Span.span_id",
"trace.v1.Span.parent_span_id",
"logs.v1.LogRecord.span_id",
"logs.v1.LogRecord.trace_id",
] {
builder = builder
.field_attribute(path, "#[cfg_attr(feature = \"with-serde\", serde(serialize_with = \"crate::proto::serializers::serialize_to_hex_string\", deserialize_with = \"crate::proto::serializers::deserialize_from_hex_string\"))]")
Expand All @@ -81,6 +83,8 @@ fn build_tonic() {
"trace.v1.Span.start_time_unix_nano",
"trace.v1.Span.end_time_unix_nano",
"trace.v1.Span.Event.time_unix_nano",
"logs.v1.LogRecord.time_unix_nano",
"logs.v1.LogRecord.observed_time_unix_nano",
] {
builder = builder
.field_attribute(path, "#[cfg_attr(feature = \"with-serde\", serde(serialize_with = \"crate::proto::serializers::serialize_u64_to_string\", deserialize_with = \"crate::proto::serializers::deserialize_string_to_u64\"))]")
Expand Down

0 comments on commit 10f99bf

Please sign in to comment.