title: Manually extracting OpenTelemetry context from golang into a string?
body: <p>I'm building a simple client server app which I want to trace across the client execution to a server microservice that calls a second server microservice.</p>
  <p>Simply speaking, it's not more complicated than CLI -&gt; ServiceA -&gt; ServiceB.</p>
  <p>The challenge I'm having is how to serialize the context - most of the docs I've looked at appear to do some form of automated HTTP header injection (e.g. <a href="https://opentelemetry.lightstep.com/core-concepts/context-propagation/" rel="nofollow noreferrer">https://opentelemetry.lightstep.com/core-concepts/context-propagation/</a>) , but I do not have access to that. I need to serialize (I think) the context of the trace/span in the client and push it to the server, where I'll rehydrate it. (Mind you, I'd love this to be simpler, but I cannot figure it out).</p>
  <p>So the object looks like this (called &quot;job&quot;):</p>
  <pre><code>    args := &amp;types.SubmitArgs{
          SerializedOtelContext: serializedOtelContext,
      }
  
      job := &amp;types.Job{}
  
      tracer := otel.GetTracerProvider().Tracer(&quot;myservice.org&quot;)
      _, span := tracer.Start(ctx, &quot;Submitting Job to RPC&quot;)
      err := system.JsonRpcMethod(rpcHost, rpcPort, &quot;Submit&quot;, args, job)
  </code></pre>
  <p>The function to submit to JsonRpcMethod is here:</p>
  <pre><code>func JsonRpcMethod(
      host string,
      port int,
      method string,
      req, res interface{},
  ) error {
      client, err := rpc.DialHTTP(&quot;tcp&quot;, fmt.Sprintf(&quot;%s:%d&quot;, host, port))
      if err != nil {
          return fmt.Errorf(&quot;Error in dialing. %s&quot;, err)
      }
      return client.Call(fmt.Sprintf(&quot;JobServer.%s&quot;, method), req, res)
  }
  </code></pre>
  <p>And the function that receives it is here:</p>
  <pre><code>func (server *JobServer) Submit(args *types.SubmitArgs, reply *types.Job) error {
      //nolint
      job, err := server.RequesterNode.Scheduler.SubmitJob(args.Spec, args.Deal)
      if err != nil {
          return err
      }
      *reply = *job
      return nil
  }
  </code></pre>
  <p>My question is how do I, in the receiving function (&quot;Submit&quot; above) extract the trace/span from the sender?</p>