/** * Default constructor construct new instance with {@link JaxrsContainerExtractor}, {@link * io.opencensus.trace.propagation.PropagationComponent#getTraceContextFormat()} and as public * endpoint. * * @see #JaxrsContainerFilter(HttpExtractor, TextFormat, Boolean) */ public JaxrsContainerFilter() { this( new JaxrsContainerExtractor(), Tracing.getPropagationComponent().getTraceContextFormat(), /* publicEndpoint= */ true); }
/** Constructs new client filter with default configuration. */ public JaxrsClientFilter() { this(new JaxrsClientExtractor(), Tracing.getPropagationComponent().getTraceContextFormat()); }
@VisibleForTesting final List<? extends ServerStreamTracer.Factory> getTracerFactories() { ArrayList<ServerStreamTracer.Factory> tracerFactories = new ArrayList<>(); if (statsEnabled) { CensusStatsModule censusStats = censusStatsOverride; if (censusStats == null) { censusStats = new CensusStatsModule( GrpcUtil.STOPWATCH_SUPPLIER, true, recordStartedRpcs, recordFinishedRpcs, recordRealTimeMetrics); } tracerFactories.add(censusStats.getServerTracerFactory()); } if (tracingEnabled) { CensusTracingModule censusTracing = new CensusTracingModule(Tracing.getTracer(), Tracing.getPropagationComponent().getBinaryFormat()); tracerFactories.add(censusTracing.getServerTracerFactory()); } tracerFactories.addAll(streamTracerFactories); tracerFactories.trimToSize(); return Collections.unmodifiableList(tracerFactories); }
@VisibleForTesting final List<ServerStreamTracer.Factory> getTracerFactories() { ArrayList<ServerStreamTracer.Factory> tracerFactories = new ArrayList<ServerStreamTracer.Factory>(); if (statsEnabled) { CensusStatsModule censusStats = this.censusStatsOverride; if (censusStats == null) { censusStats = new CensusStatsModule(GrpcUtil.STOPWATCH_SUPPLIER, true); } tracerFactories.add( censusStats.getServerTracerFactory(recordStartedRpcs, recordFinishedRpcs)); } if (tracingEnabled) { CensusTracingModule censusTracing = new CensusTracingModule(Tracing.getTracer(), Tracing.getPropagationComponent().getBinaryFormat()); tracerFactories.add(censusTracing.getServerTracerFactory()); } tracerFactories.addAll(streamTracerFactories); return tracerFactories; }
@VisibleForTesting final List<ClientInterceptor> getEffectiveInterceptors() { List<ClientInterceptor> effectiveInterceptors = new ArrayList<ClientInterceptor>(this.interceptors); if (statsEnabled) { retryDisabled = true; CensusStatsModule censusStats = this.censusStatsOverride; if (censusStats == null) { censusStats = new CensusStatsModule(GrpcUtil.STOPWATCH_SUPPLIER, true); } // First interceptor runs last (see ClientInterceptors.intercept()), so that no // other interceptor can override the tracer factory we set in CallOptions. effectiveInterceptors.add( 0, censusStats.getClientInterceptor(recordStartedRpcs, recordFinishedRpcs)); } if (tracingEnabled) { retryDisabled = true; CensusTracingModule censusTracing = new CensusTracingModule(Tracing.getTracer(), Tracing.getPropagationComponent().getBinaryFormat()); effectiveInterceptors.add(0, censusTracing.getClientInterceptor()); } return effectiveInterceptors; }
/** Create a new {@code OcJettyHttpClient}. */ public OcJettyHttpClient() { super(); OcJettyHttpClientExtractor extractor = new OcJettyHttpClientExtractor(); handler = new HttpClientHandler<Request, Response, Request>( Tracing.getTracer(), extractor, Tracing.getPropagationComponent().getTraceContextFormat(), setter); }
@VisibleForTesting final List<ClientInterceptor> getEffectiveInterceptors() { List<ClientInterceptor> effectiveInterceptors = new ArrayList<>(this.interceptors); temporarilyDisableRetry = false; if (statsEnabled) { temporarilyDisableRetry = true; CensusStatsModule censusStats = this.censusStatsOverride; if (censusStats == null) { censusStats = new CensusStatsModule( GrpcUtil.STOPWATCH_SUPPLIER, true, recordStartedRpcs, recordFinishedRpcs, recordRealTimeMetrics); } // First interceptor runs last (see ClientInterceptors.intercept()), so that no // other interceptor can override the tracer factory we set in CallOptions. effectiveInterceptors.add(0, censusStats.getClientInterceptor()); } if (tracingEnabled) { temporarilyDisableRetry = true; CensusTracingModule censusTracing = new CensusTracingModule(Tracing.getTracer(), Tracing.getPropagationComponent().getBinaryFormat()); effectiveInterceptors.add(0, censusTracing.getClientInterceptor()); } return effectiveInterceptors; }
@Test public void implementationOfBinaryPropagationHandler() { assertThat(Tracing.getPropagationComponent()).isInstanceOf(PropagationComponentImpl.class); }
@Test public void implementationOfBinaryPropagationHandler() { assertThat(Tracing.getPropagationComponent()).isInstanceOf(PropagationComponent.class); }
static HttpServerHandler<HttpServletRequest, HttpServletResponse, HttpServletRequest> buildHttpServerHandler() { return new HttpServerHandler<HttpServletRequest, HttpServletResponse, HttpServletRequest>( Tracing.getTracer(), // TODO[rghetia]: // 1. provide options to configure custom extractor, propagator and endpoint. new OcHttpServletExtractor(), Tracing.getPropagationComponent().getTraceContextFormat(), getter, true); }
@Test public void defaultBinaryPropagationHandler() { assertThat(Tracing.getPropagationComponent()) .isSameAs(PropagationComponent.getNoopPropagationComponent()); }