8000 Export TraceData wrapped ResourceSpans by joshwlewis · Pull Request #916 · heroku/libcnb.rs · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Export TraceData wrapped ResourceSpans #916

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

Merged
merged 1 commit into from
Feb 27, 2025
Merged
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
11 changes: 9 additions & 2 deletions libcnb/src/tracing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ use opentelemetry::{
global::{self, BoxedSpan},
trace::{Span as SpanTrait, Status, Tracer, TracerProvider as TracerProviderTrait},
};
use opentelemetry_proto::transform::common::tonic::ResourceAttributesWithSchema;
use opentelemetry_proto::transform::trace::tonic::group_spans_by_resource_and_scope;
use opentelemetry_proto::{
tonic::trace::v1::TracesData, transform::common::tonic::ResourceAttributesWithSchema,
};
use opentelemetry_sdk::{
Resource,
error::{OTelSdkError, OTelSdkResult},
Expand Down Expand Up @@ -144,7 +146,9 @@ impl<W: Write + Send + Debug> SpanExporter for FileExporter<W> {
batch: Vec<opentelemetry_sdk::trace::SpanData>,
) -> BoxFuture<'static, OTelSdkResult> {
let resource = ResourceAttributesWithSchema::from(&self.resource);
let data = group_spans_by_resource_and_scope(batch, &resource);
let resource_spans = group_spans_by_resource_and_scope(batch, &resource);
let data = TracesData { resource_spans };

let mut writer = match self.writer.lock() {
Ok(f) => f,
Err(e) => {
Expand Down Expand Up @@ -217,6 +221,9 @@ mod tests {
let _tracing_data: Value = serde_json::from_str(&tracing_contents)
.expect("Expected tracing export file contents to be valid json");

// Check top level structure
assert!(tracing_contents.contains("{\"resourceSpans\":[{\"resource\":"));

// Check resource attributes
assert!(tracing_contents.contains(
"{\"key\":\"service.name\",\"value\":{\"stringValue\":\"company.com/foo\"}}"
Expand Down
Loading
0