0

We are migrating from open-tracing to open telemetry .

We have inject function like below in open-tracing.

getTracer().inject(getActiveSpanContet(), Builtin.HTTP_HEADERS, new TextMapAdapter(contextValues));

Could some one please help what would be equivalent for same in openTelemetry? I tried searching on google I couldn’t get equivalent for same .

santosh jk
  • 111
  • 1
  • 11

1 Answers1

1

OpenTelemetry has a similar inject method on the Propagators API

openTelemetry.getPropagators().getTextMapPropagator().inject(Context.current(), transportLayer, setter);
Tyler B
  • 308
  • 2
  • 9
  • thanks Tyler for your reply , I have seen this , here transport layer expectation is to create new http connection , but in open telemetry there is no need to create new http connection right ? – santosh jk Aug 08 '23 at 02:16
  • `transportLayer` would be the http request that is passed to the setter for updating the http headers according to the configured propagator. The link I provided shows the full example. – Tyler B Aug 14 '23 at 16:26