Skip to content

Commit

Permalink
otel: add header parsing and test call state
Browse files Browse the repository at this point in the history
Enables Unit to parse the tracestate and traceparent headers and add it
to the list, as well as calls to nxt_otel_test_and_call_state.

Signed-off-by: Gabor Javorszky <g.javorszky@f5.com>
Signed-off-by: Ava Hahn <a.hahn@f5.com>

Co-authored-by: Ava Hahn <a.hahn@f5.com>
  • Loading branch information
javorszky and avahahn committed Oct 18, 2024
1 parent f68c642 commit 75f8734
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/nxt_h1proto.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,10 @@ static nxt_http_field_proc_t nxt_h1p_fields[] = {
{ nxt_string("Content-Length"), &nxt_http_request_content_length, 0 },
{ nxt_string("Authorization"), &nxt_http_request_field,
offsetof(nxt_http_request_t, authorization) },
#if (NXT_HAVE_OTEL)
{ nxt_string("Traceparent"), &nxt_otel_parse_traceparent, 0 },
{ nxt_string("Tracestate"), &nxt_otel_parse_tracestate, 0 },
#endif
};


Expand Down Expand Up @@ -518,6 +522,10 @@ nxt_h1p_conn_request_init(nxt_task_t *task, void *obj, void *data)
h1p->parser.discard_unsafe_fields = skcf->discard_unsafe_fields;

nxt_h1p_conn_request_header_parse(task, c, h1p);
#if (NXT_HAVE_OTEL)
nxt_otel_test_and_call_state(task, r);
#endif

return;
}

Expand Down Expand Up @@ -1332,6 +1340,10 @@ nxt_h1p_request_header_send(nxt_task_t *task, nxt_http_request_t *r,

nxt_debug(task, "h1p request header send");

#if (NXT_HAVE_OTEL)
nxt_otel_test_and_call_state(task, r);
#endif

r->header_sent = 1;
h1p = r->proto.h1;
n = r->status;
Expand Down
12 changes: 12 additions & 0 deletions src/nxt_http_request.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
#include <nxt_router.h>
#include <nxt_http.h>

#if(NXT_HAVE_OTEL)
#include <nxt_otel.h>
#endif


static nxt_int_t nxt_http_validate_host(nxt_str_t *host, nxt_mp_t *mp);
static void nxt_http_request_start(nxt_task_t *task, void *obj, void *data);
Expand Down Expand Up @@ -319,6 +323,10 @@ nxt_http_request_start(nxt_task_t *task, void *obj, void *data)

r = obj;

#if (NXT_HAVE_OTEL)
nxt_otel_test_and_call_state(task, r);
#endif

r->state = &nxt_http_request_body_state;

skcf = r->conf->socket_conf;
Expand Down Expand Up @@ -590,6 +598,10 @@ nxt_http_request_ready(nxt_task_t *task, void *obj, void *data)
r = obj;
action = r->conf->socket_conf->action;

#if (NXT_HAVE_OTEL)
nxt_otel_test_and_call_state(task, r);
#endif

if (r->chunked) {
ret = nxt_http_request_chunked_transform(r);
if (nxt_slow_path(ret != NXT_OK)) {
Expand Down

0 comments on commit 75f8734

Please sign in to comment.