Adding custom fields to http_wrapper for tracing purposes

Hello,

I want to add traces to my simulated 5G Network (free5GC + UERANSIM). I know that the proper way to do it would be with kubernetes/istio but I find those orchestrators a bit overkill in my case. I only want a basic tracing system that add a trace-id in a http request if the variable isn’t present then propagate it to the responses and other requests from the same flow/communication (example every http packet that takes part in a Registration process would have the same trace-id).

I intended to edit thes files in /free5gc/http_wrapper but I don’t really know how to proceed nor if my method is feasible at all. I’d be also glad to hear if are other methods that I don’t know about and how you would approach this problem.

Have a nice day

Hi,

I understand your question. Modifying the http_wrapper should be feasible. However, I suggest directly adding the Trace-ID to the HTTP request within openapi/client.go. This would be a simpler approach. Specifically, you can add the logic to check and set the Trace-ID in the PrepareRequest function and ensure that this Trace-ID is propagated in all HTTP requests and responses.

Wishing you smooth development

Hello and thank you very much for your answer.

I don’t know about openapi or client.go could you please elaborate ?
Im not 100% sure if it’s what you’re talking about but I already considered injecting a new field in the outgoing packets. For me this method would only work in the case of a simple request/response exchange but won’t be enough when dealing with procedures that involve multiple exchanges between multiples NF (for example the registration procedure). I don’t see, in the case of a procedure, any way to know as an outsider
if a given request is part of a procedure (an thus should have the same trace-id).

If you have any ideas about the propagation method and/or insights about openapi/client.go i would be glad to hear more about it.

Have a nice day

Hi,

After discussing with my team lead, I realized that modifying openapi/client.go alone won’t be sufficient if you want to maintain the same Trace-ID across multiple NF-to-NF communications.

Why this is the case:
Each NF in free5GC communicates with others using a new context for every request. This means that when a procedure involves multiple NFs (like the registration process), each NF will create a new context, resulting in a different Trace-ID if we only modify the client code.

What needs to be done:
To achieve consistent Trace-ID propagation across multiple NFs, we need to:

Modify each NF’s internal code to pass the same Trace-ID within the context for related requests.
Implement a shared context or identifier management system that keeps the same Trace-ID for the entire procedure.

Alternative:
If you only need to add a Trace-ID to each request without maintaining the same ID across multiple NFs, modifying the HTTP wrapper in openapi might be sufficient. However, this won’t work for complex multi-NF scenarios.

Let me know if this explanation helps! If you want to go into more details on how to manage contexts between NFs, I’d be glad to discuss it further.

Wishing you smooth development!

Have a nice day! :blush:

Hello and thank you again for your answer.
I indeed need to propagate the trace-ID across multiple NFs which seem impossible with header injection. Modifying the code could be a solution but I’d rather do it as a last resort because it seem like a lot of work to implement and maintain.

Im pretty sure another solution would be to use tracing tools like istio / envoy proxy that uses sidecars to add trace-id. Im currently trying to do it this way but I encounter some issues with kubernetes and that’s why I created another topic in the forum : Xxsslkey.log location with helm deployment

Thanks and have a nice day

1 Like