Skip to content

Commit

Permalink
refactor build tooling to be more idiomatic
Browse files Browse the repository at this point in the history
Signed-off-by: Ava Hahn <a.hahn@f5.com>
  • Loading branch information
avahahn committed Sep 19, 2024
1 parent 473bb10 commit e7c4c8a
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 25 deletions.
38 changes: 18 additions & 20 deletions auto/otel
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,21 @@
nxt_found=no
NXT_HAVE_OTEL=NO

cd src/otel
cargo build
cd ../../

nxt_feature="otel"
nxt_feature_name=NXT_HAVE_OTEL
nxt_feature_run=no
nxt_feature_libs=""
nxt_feature_test="int main(void){return 0;}"

. auto/feature

if [ $nxt_found = no ]; then
$echo
$echo $0: error: no OpenTelemetry library found.
$echo
exit 1;
fi

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

cat << END >> $NXT_AUTO_CONFIG_H
#ifndef NXT_HAVE_OTEL
#define NXT_HAVE_OTEL 1
#endif
END

NXT_LIB_AUX_LIBS="$NXT_LIB_AUX_LIBS $(pkgconf openssl --cflags --libs || "-lssl -lcrypto") $NXT_OTEL_LIB_LOC"

cat << END >> $NXT_MAKEFILE

$NXT_OTEL_LIB_LOC:
pushd $NXT_BUILD_DIR/src/otel/
cargo build
cd ../../

END
2 changes: 1 addition & 1 deletion auto/ssltls
Original file line number Diff line number Diff line change
Expand Up @@ -212,4 +212,4 @@ if [ $NXT_POLARSSL = YES ]; then
$echo
exit 1;
fi
fi
fi
3 changes: 2 additions & 1 deletion src/nxt_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
*/

#include <nxt_main.h>
extern char **environ;
#include <nxt_runtime.h>
extern char **environ;

int nxt_cdecl
main(int argc, char **argv)
Expand Down
1 change: 1 addition & 0 deletions src/nxt_main.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ typedef void (*nxt_event_conn_handler_t)(nxt_thread_t *thr, nxt_conn_t *c);
#include <nxt_runtime.h>
#include <nxt_port_hash.h>


/*
* The envp argument must be &environ if application may
* change its process title with nxt_process_title().
Expand Down
8 changes: 5 additions & 3 deletions src/nxt_otel.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* Copyright (C) F5, Inc.
*/

#include "nxt_clang.h"
#include <math.h>

#include <nxt_router.h>
Expand All @@ -22,7 +23,7 @@
#define NXT_OTEL_PATH_TAG "path"


static inline void
nxt_inline void
nxt_otel_state_transition(nxt_otel_state_t *state, nxt_otel_status_t status)
{
if (status == NXT_OTEL_ERROR_STATE || state->status != NXT_OTEL_ERROR_STATE) {
Expand All @@ -31,7 +32,7 @@ nxt_otel_state_transition(nxt_otel_state_t *state, nxt_otel_status_t status)
}


static inline void
nxt_inline void
nxt_otel_trace_and_span_init(nxt_task_t *t, nxt_http_request_t *r)
{
r->otel->trace =
Expand Down Expand Up @@ -132,6 +133,7 @@ nxt_otel_span_add_headers(nxt_task_t *t, nxt_http_request_t *r)
if (f == NULL) {
nxt_log(t, NXT_LOG_ERR,
"couldnt allocate traceparent header in response");
goto next;
}

nxt_http_field_name_set(f, "traceparent");
Expand Down Expand Up @@ -183,7 +185,7 @@ nxt_otel_send_trace_and_span_data(nxt_task_t *task, void *obj, void *data)
}


static inline void
nxt_inline void
nxt_otel_span_collect(nxt_task_t *t, nxt_http_request_t *r)
{
nxt_log(t, NXT_LOG_DEBUG, "collecting span by adding the task to the fast work queue");
Expand Down

0 comments on commit e7c4c8a

Please sign in to comment.