0

We use dapr, which sends requests against our api and each request contains a body including a traceid attribute. We want to use this trace id to build "contigous traces", something like this (pseudo-code):

@app.post("/api/doit")
def post_doit(request: Request):
    get_json = async_to_sync(request.json)
    data = get_json()
    trace_id = data['traceid']
    # do something to let me add a span related to the parent trace id
    with tracer.start_as_current_span("/api/doit"):
        request.post("some-outgoing-call")  # this operation should be captured as a child of the "trace id" trace
        return {"status": "SUCCESS"}

I'm struggling to find documentation on how to do this in the opentelemetry documentation. In "old" opentracing there was some "extract" methods for creating spans based on existing data from http headers etc, but I can 't find anything similar in opemtelemetry tracing. Any pointers very much appreciated!

Trondh
  • 3,221
  • 1
  • 25
  • 34
  • 1
    Please find one of old answers https://stackoverflow.com/questions/68530363/opentelemetry-python-how-to-instanciate-a-new-span-as-a-child-span-for-a-given/68552837#68552837. Let me know if that doesn't help – Srikanth Chekuri Oct 25 '21 at 14:40
  • awesome, that should get me going. Thanks! – Trondh Oct 25 '21 at 15:51
  • Vote the question and answer so that it shows up in search and people don't create new issue for same purpose. – Srikanth Chekuri Oct 26 '21 at 00:52

0 Answers0