forked from fermyon/spin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(telemetry): Add a compatibility layer that emits app logs as tra…
…cing events. Signed-off-by: Caleb Schoepp <caleb.schoepp@fermyon.com>
- Loading branch information
1 parent
c44da5f
commit fc1f835
Showing
7 changed files
with
188 additions
and
66 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
use std::sync::OnceLock; | ||
|
||
use crate::env; | ||
|
||
/// Takes a Spin application log and emits it as a tracing event. This acts as a compatibility layer | ||
/// to easily get Spin app logs as events∆1 in our OTel traces. | ||
pub fn app_log_to_tracing_event(buf: &[u8]) { | ||
static CELL: OnceLock<bool> = OnceLock::new(); | ||
if *CELL.get_or_init(env::app_log_to_tracing_event_disabled) { | ||
return; | ||
} | ||
|
||
if let Ok(s) = std::str::from_utf8(buf) { | ||
tracing::info!(app_log = s); | ||
} else { | ||
tracing::info!(app_log = "Application log: <non-utf8 data>"); | ||
} | ||
} |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.