Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update serialization format for LogRecord fields. #1771

Merged
merged 5 commits into from
May 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading