Skip to content

Commit

Permalink
Additionally transform hyphens to underscores for trace names
Browse files Browse the repository at this point in the history
  • Loading branch information
joshwlewis committed Nov 30, 2023
1 parent 4edd307 commit 5b911db
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 4 additions & 1 deletion libcnb/src/tracing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ pub(crate) struct BuildpackTrace {
/// Open Telemetry file export. The resulting trace provider and span are
/// enriched with data from the buildpack and the rust environment.
pub(crate) fn start_trace(buildpack: &Buildpack, phase_name: &'static str) -> BuildpackTrace {
let trace_name = format!("{}-{phase_name}", buildpack.id.replace(['/', '.'], "_"));
let trace_name = format!(
"{}-{phase_name}",
buildpack.id.replace(['/', '.', '-'], "_")
);
let tracing_file_path = Path::new(TELEMETRY_EXPORT_ROOT).join(format!("{trace_name}.jsonl"));

// Ensure tracing file path parent exists by creating it.
Expand Down
4 changes: 2 additions & 2 deletions test-buildpacks/tracing/tests/integration_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ fn test_tracing_export_file() {
TestRunner::default().build(&build_config, |context| {
// Ensure expected span names for detect and build phases are present
// in the file export contents.
assert_contains!(context.pack_stdout, "libcnb-test-buildpacks_tracing-detect");
assert_contains!(context.pack_stdout, "libcnb-test-buildpacks_tracing-build");
assert_contains!(context.pack_stdout, "libcnb_test_buildpacks_tracing-detect");
assert_contains!(context.pack_stdout, "libcnb_test_buildpacks_tracing-build");
});
}

0 comments on commit 5b911db

Please sign in to comment.