This repository has been archived by the owner on Jun 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix up some encoding issues with tracing
- Loading branch information
Showing
8 changed files
with
129 additions
and
142 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,52 @@ | ||
mod export_logs_service; | ||
mod log_record; | ||
|
||
use emit_batcher::BatchError; | ||
|
||
pub use self::{export_logs_service::*, log_record::*}; | ||
|
||
use super::{AnyValue, PreEncoded}; | ||
|
||
pub(crate) fn encode_event( | ||
evt: &emit_core::event::Event<impl emit_core::props::Props>, | ||
) -> PreEncoded { | ||
let time_unix_nano = evt | ||
.extent() | ||
.map(|extent| extent.to_point().to_unix_time().as_nanos() as u64) | ||
.unwrap_or_default(); | ||
|
||
let observed_time_unix_nano = time_unix_nano; | ||
|
||
let protobuf = sval_protobuf::stream_to_protobuf(LogRecord { | ||
time_unix_nano, | ||
observed_time_unix_nano, | ||
body: &Some(AnyValue::<_, (), (), ()>::String(&sval::Display::new( | ||
evt.tpl(), | ||
))), | ||
attributes: &PropsLogRecordAttributes(evt.props()), | ||
dropped_attributes_count: 0, | ||
flags: Default::default(), | ||
}); | ||
|
||
PreEncoded::Proto(protobuf) | ||
} | ||
|
||
pub(crate) fn encode_request( | ||
resource: Option<&PreEncoded>, | ||
scope: Option<&PreEncoded>, | ||
log_records: &[PreEncoded], | ||
) -> Result<PreEncoded, BatchError<Vec<PreEncoded>>> { | ||
Ok(PreEncoded::Proto(sval_protobuf::stream_to_protobuf( | ||
ExportLogsServiceRequest { | ||
resource_logs: &[ResourceLogs { | ||
resource: &resource, | ||
scope_logs: &[ScopeLogs { | ||
scope: &scope, | ||
log_records, | ||
schema_url: "", | ||
}], | ||
schema_url: "", | ||
}], | ||
}, | ||
))) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,56 @@ | ||
mod export_trace_service; | ||
mod span; | ||
|
||
use emit_batcher::BatchError; | ||
|
||
pub use self::{export_trace_service::*, span::*}; | ||
|
||
use super::PreEncoded; | ||
|
||
pub(crate) fn encode_event( | ||
evt: &emit_core::event::Event<impl emit_core::props::Props>, | ||
) -> Option<PreEncoded> { | ||
let (start_time_unix_nano, end_time_unix_nano) = evt | ||
.extent() | ||
.and_then(|extent| extent.as_span()) | ||
.map(|span| { | ||
( | ||
span.start.to_unix_time().as_nanos() as u64, | ||
span.end.to_unix_time().as_nanos() as u64, | ||
) | ||
})?; | ||
|
||
let protobuf = sval_protobuf::stream_to_protobuf(Span { | ||
start_time_unix_nano, | ||
end_time_unix_nano, | ||
name: &sval::Display::new(evt.tpl()), | ||
attributes: &PropsSpanAttributes { | ||
time_unix_nano: end_time_unix_nano, | ||
props: evt.props(), | ||
}, | ||
dropped_attributes_count: 0, | ||
kind: SpanKind::Unspecified, | ||
}); | ||
|
||
Some(PreEncoded::Proto(protobuf)) | ||
} | ||
|
||
pub(crate) fn encode_request( | ||
resource: Option<&PreEncoded>, | ||
scope: Option<&PreEncoded>, | ||
spans: &[PreEncoded], | ||
) -> Result<PreEncoded, BatchError<Vec<PreEncoded>>> { | ||
Ok(PreEncoded::Proto(sval_protobuf::stream_to_protobuf( | ||
ExportTraceServiceRequest { | ||
resource_spans: &[ResourceSpans { | ||
resource: &resource, | ||
scope_spans: &[ScopeSpans { | ||
scope: &scope, | ||
spans, | ||
schema_url: "", | ||
}], | ||
schema_url: "", | ||
}], | ||
}, | ||
))) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.