How to pass tracing information in custom actions for end-to-end tracing

I am working on a project that requires building a smart chatbot that enables commerce list/cart building. I have all the components of the architecture working however I need to enable end to end tracing that contains things like user_id, session Id and request Id.

The incoming call to Rasa core API have session and request Id in the header and I need to pass it through to custom actions so logs can have the end-to-end view.

I have noticed that in the class action_endpoint doesn’t pass any incoming request header through:

response = self.action_endpoint.request( json=json, method=“post”, timeout=DEFAULT_REQUEST_TIMEOUT)

My custom channel is a using flask so arguably I should be able to pass along my custom headers doing something like

response = self.action_endpoint.request( json=json, headers= request.headers, method=“post”, timeout=DEFAULT_REQUEST_TIMEOUT)

Since I am new to Python (not new to programming) I have two concerns:

  • Not fully knowing the internals of Flask is this thread safe?
  • Is there another extension point that I can use to enable passing custom headers to my custom action endpoints?

I will be more than happy to create a PR if this is valid approach.

1 Like