Skip to content

Commit a828a14

Browse files
javorszkyavahahn
authored andcommitted
Move CString init out of log_callback arg
1 parent d949513 commit a828a14

File tree

5 files changed

+14
-15
lines changed

5 files changed

+14
-15
lines changed

auto/make

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ $NXT_BUILD_DIR/sbin/$NXT_DAEMON: $NXT_BUILD_DIR/lib/$NXT_LIB_STATIC \\
362362
\$(NXT_OBJS)
363363
\$(PP_LD) \$@
364364
\$(v)\$(NXT_EXEC_LINK) -o \$@ \$(CFLAGS) \\
365-
\$(NXT_OBJS) $NXT_BUILD_DIR/lib/$NXT_LIB_STATIC src/otel/target/debug/libotel.a \\
365+
\$(NXT_OBJS) $NXT_BUILD_DIR/lib/$NXT_LIB_STATIC \\
366366
$NXT_LIBM $NXT_LIBS $NXT_LIB_AUX_LIBS
367367

368368
END

auto/otel

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ cd ../../
1616
nxt_feature="otel"
1717
nxt_feature_name=NXT_HAVE_OTEL
1818
nxt_feature_run=no
19-
nxt_feature_libs=
19+
nxt_feature_libs=""
2020
nxt_feature_test="int main(void){return 0;}"
2121

2222
. auto/feature
@@ -27,3 +27,5 @@ if [ $nxt_found = no ]; then
2727
$echo
2828
exit 1;
2929
fi
30+
31+
NXT_LIB_AUX_LIBS="$NXT_LIB_AUX_LIBS -lssl -lcrypto src/otel/target/debug/libotel.a"

src/nxt_h1proto.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1837,10 +1837,9 @@ nxt_h1p_conn_sent(nxt_task_t *task, void *obj, void *data)
18371837
{
18381838
nxt_conn_t *c;
18391839
nxt_event_engine_t *engine;
1840+
#if (NXT_HAVE_OTEL)
18401841
nxt_http_request_t *r;
18411842
r = ((nxt_h1proto_t *) data)->request;
1842-
1843-
#if (NXT_HAVE_OTEL)
18441843
nxt_otel_test_and_call_state(task, r);
18451844
#endif
18461845

src/nxt_main.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ main(int argc, char **argv)
2929

3030
nxt_main_log.handler = nxt_log_time_handler;
3131

32-
nxt_otel_init(otel_phase1_log_callback);
32+
#if (NXT_HAVE_OTEL)
33+
nxt_otel_init(&otel_phase1_log_callback);
34+
#endif
3335
ret = nxt_runtime_create(&nxt_main_task);
3436

3537
if (ret != NXT_OK) {

src/otel/src/lib.rs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,18 +38,14 @@ unsafe fn nxt_otel_init(log_callback: unsafe extern "C" fn(*mut i8)) {
3838

3939
// unwrap
4040
match res {
41-
Err(e) => log_callback(
42-
CString::from_vec_unchecked(e.to_string().as_bytes().to_vec())
43-
.into_raw() as _,
44-
),
41+
Err(e) => {
42+
let msg =CString::from_vec_unchecked(e.to_string().as_bytes().to_vec());
43+
log_callback(msg.into_raw() as _)
44+
},
4545
Ok(t) => {
4646
GLOBAL_TRACER_PROVIDER.get_or_init(move || t);
47-
log_callback(
48-
CString::from_vec_unchecked(
49-
"otel exporter has been initialised".as_bytes().to_vec(),
50-
)
51-
.into_raw() as _,
52-
);
47+
let msg = CString::from_vec_unchecked("otel exporter has been initialised".as_bytes().to_vec());
48+
log_callback(msg.into_raw() as _);
5349
}
5450
}
5551
}

0 commit comments

Comments
 (0)