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

Move CString init out of log_callback arg #12

Merged
merged 3 commits into from
Aug 13, 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
4 changes: 2 additions & 2 deletions auto/otel
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ cd src/otel
cargo build
cd ../../


nxt_feature="otel"
nxt_feature_name=NXT_HAVE_OTEL
nxt_feature_run=no
Expand All @@ -29,4 +28,5 @@ if [ $nxt_found = no ]; then
exit 1;
fi

NXT_LIB_AUX_LIBS="$NXT_LIB_AUX_LIBS -lssl -lcrypto src/otel/target/debug/libotel.a"

NXT_LIB_AUX_LIBS="$NXT_LIB_AUX_LIBS -lssl -lcrypto src/otel/target/debug/libotel.a"
16 changes: 6 additions & 10 deletions src/otel/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,14 @@ unsafe fn nxt_otel_init(log_callback: unsafe extern "C" fn(*mut i8)) {

// unwrap
match res {
Err(e) => log_callback(
CString::from_vec_unchecked(e.to_string().as_bytes().to_vec())
.into_raw() as _,
),
Err(e) => {
let msg =CString::from_vec_unchecked(e.to_string().as_bytes().to_vec());
log_callback(msg.into_raw() as _)
},
Ok(t) => {
GLOBAL_TRACER_PROVIDER.get_or_init(move || t);
log_callback(
CString::from_vec_unchecked(
"otel exporter has been initialised".as_bytes().to_vec(),
)
.into_raw() as _,
);
let msg = CString::from_vec_unchecked("otel exporter has been initialised".as_bytes().to_vec());
log_callback(msg.into_raw() as _);
}
}
}
Expand Down