use of io.grpc.internal.ForwardingClientStreamTracer in project grpc-java by grpc.
the class TokenAttachingTracerFactory method newClientStreamTracer.
@Override
public ClientStreamTracer newClientStreamTracer(ClientStreamTracer.StreamInfo info, Metadata headers) {
if (delegate == null) {
return NOOP_TRACER;
}
final ClientStreamTracer clientStreamTracer = delegate.newClientStreamTracer(info, headers);
class TokenPropagationTracer extends ForwardingClientStreamTracer {
@Override
protected ClientStreamTracer delegate() {
return clientStreamTracer;
}
@Override
public void streamCreated(Attributes transportAttrs, Metadata headers) {
Attributes eagAttrs = checkNotNull(transportAttrs.get(GrpcAttributes.ATTR_CLIENT_EAG_ATTRS), "eagAttrs");
String token = eagAttrs.get(GrpclbConstants.TOKEN_ATTRIBUTE_KEY);
headers.discardAll(GrpclbConstants.TOKEN_METADATA_KEY);
if (token != null) {
headers.put(GrpclbConstants.TOKEN_METADATA_KEY, token);
}
delegate().streamCreated(transportAttrs, headers);
}
}
return new TokenPropagationTracer();
}
Aggregations