use of io.opentelemetry.javaagent.instrumentation.rmi.context.ContextPayload in project opentelemetry-java-instrumentation by open-telemetry.
the class ContextDispatcher method dispatch.
@Override
// Instrumenting deprecated class
@SuppressWarnings("deprecation")
public void dispatch(Remote obj, java.rmi.server.RemoteCall call) throws IOException {
ObjectInput in = call.getInputStream();
int operationId = in.readInt();
// skip 8 bytes
in.readLong();
if (PROPAGATOR.isOperationWithPayload(operationId)) {
ContextPayload payload = ContextPayload.read(in);
if (payload != null) {
Context context = payload.extract();
SpanContext spanContext = Span.fromContext(context).getSpanContext();
if (spanContext.isValid()) {
THREAD_LOCAL_CONTEXT.set(context);
} else {
THREAD_LOCAL_CONTEXT.set(null);
}
}
}
// send result stream the client is expecting
call.getResultStream(true);
// release held streams to allow next call to continue
call.releaseInputStream();
call.releaseOutputStream();
call.done();
}
Aggregations