Search in sources :

Example 1 with StreamTracer

use of io.grpc.StreamTracer in project grpc-java by grpc.

the class NettyServerHandlerTest method streamTracerCreated.

@Test
public void streamTracerCreated() throws Exception {
    manualSetUp();
    createStream();
    verify(streamTracerFactory).newServerStreamTracer(eq("foo/bar"), any(Metadata.class));
    StatsTraceContext statsTraceCtx = stream.statsTraceContext();
    List<StreamTracer> tracers = statsTraceCtx.getTracersForTest();
    assertEquals(1, tracers.size());
    assertSame(streamTracer, tracers.get(0));
}
Also used : StatsTraceContext(io.grpc.internal.StatsTraceContext) Metadata(io.grpc.Metadata) ServerStreamTracer(io.grpc.ServerStreamTracer) StreamTracer(io.grpc.StreamTracer) TestServerStreamTracer(io.grpc.internal.testing.TestServerStreamTracer) Test(org.junit.Test)

Example 2 with StreamTracer

use of io.grpc.StreamTracer in project grpc-java by grpc.

the class StatsTraceContext method serverFilterContext.

/**
 * See {@link ServerStreamTracer#filterContext}.  For server-side only.
 *
 * <p>Called from {@link io.grpc.internal.ServerImpl}.
 */
public <ReqT, RespT> Context serverFilterContext(Context context) {
    Context ctx = checkNotNull(context, "context");
    for (StreamTracer tracer : tracers) {
        ctx = ((ServerStreamTracer) tracer).filterContext(ctx);
        checkNotNull(ctx, "%s returns null context", tracer);
    }
    return ctx;
}
Also used : Context(io.grpc.Context) ServerStreamTracer(io.grpc.ServerStreamTracer) StreamTracer(io.grpc.StreamTracer) ClientStreamTracer(io.grpc.ClientStreamTracer)

Aggregations

ServerStreamTracer (io.grpc.ServerStreamTracer)2 StreamTracer (io.grpc.StreamTracer)2 ClientStreamTracer (io.grpc.ClientStreamTracer)1 Context (io.grpc.Context)1 Metadata (io.grpc.Metadata)1 StatsTraceContext (io.grpc.internal.StatsTraceContext)1 TestServerStreamTracer (io.grpc.internal.testing.TestServerStreamTracer)1 Test (org.junit.Test)1