io.opentracing.noop.NoopTracerFactory Java Examples
The following examples show how to use
io.opentracing.noop.NoopTracerFactory.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JdbcDeviceRegsitryTenantCleaner.java From enmasse with Apache License 2.0 | 6 votes |
public JdbcDeviceRegsitryTenantCleaner() throws Exception { final ObjectMapper mapper = new ObjectMapper(); final JdbcDeviceProperties devices = mapper.readValue(System.getenv("jdbc.devices"), JdbcDeviceProperties.class); if (devices.getManagement() != null) { this.devices = DeviceStores.store( this.vertx, NoopTracerFactory.create(), devices, JdbcDeviceProperties::getManagement, DeviceStores.managementStoreFactory()); } else { this.devices = null; } }
Example #2
Source File: TracerFactory.java From Jupiter with Apache License 2.0 | 6 votes |
private static Tracer loadTracer() { try { Iterator<Tracer> implementations = JServiceLoader.load(Tracer.class).iterator(); if (implementations.hasNext()) { Tracer first = implementations.next(); if (!implementations.hasNext()) { return first; } logger.warn("More than one tracer is found, NoopTracer will be used as default."); return NoopTracerFactory.create(); } } catch (Throwable t) { logger.error("Load tracer failed: {}.", StackTraceUtil.stackTrace(t)); } return NoopTracerFactory.create(); }
Example #3
Source File: TestRemoteNodeFileSystemDual.java From dremio-oss with Apache License 2.0 | 6 votes |
public ServiceHolder(Provider<Iterable<NodeEndpoint>> nodeProvider, PDFSMode mode, String name) throws Exception{ this.allocator = allocatorRule.newAllocator(name, 0, Long.MAX_VALUE); pool = new CloseableThreadPool(name); fabric = new FabricServiceImpl(HOSTNAME, 9970, true, THREAD_COUNT, this.allocator, RESERVATION, MAX_ALLOCATION, TIMEOUT, pool); fabric.start(); endpoint = NodeEndpoint.newBuilder() .setAddress(fabric.getAddress()).setFabricPort(fabric.getPort()) .setRoles(Roles.newBuilder().setJavaExecutor(mode == PDFSMode.DATA)) .build(); service = new PDFSService(DirectProvider.wrap((FabricService) fabric), DirectProvider.wrap(endpoint), nodeProvider, NoopTracerFactory.create(), DremioTest.DEFAULT_SABOT_CONFIG, this.allocator, mode); service.start(); fileSystem = service.createFileSystem(); }
Example #4
Source File: TracerConfigurator.java From lucene-solr with Apache License 2.0 | 6 votes |
public static void loadTracer(SolrResourceLoader loader, PluginInfo info, ZkStateReader stateReader) { if (info == null) { // in case of a Tracer is registered to OpenTracing through javaagent if (io.opentracing.util.GlobalTracer.isRegistered()) { GlobalTracer.setup(io.opentracing.util.GlobalTracer.get()); registerListener(stateReader); } else { GlobalTracer.setup(NoopTracerFactory.create()); GlobalTracer.get().setSamplePercentage(0.0); } } else { TracerConfigurator configurator = loader .newInstance(info.className, TracerConfigurator.class); configurator.init(info.initArgs); GlobalTracer.setup(configurator.getTracer()); registerListener(stateReader); } }
Example #5
Source File: HonoClientUnitTestHelper.java From hono with Eclipse Public License 2.0 | 6 votes |
/** * Creates a mocked Hono connection that returns a * Noop Tracer. * * @param vertx The vert.x instance to use. * @param props The client properties to use. * @return The connection. */ public static HonoConnection mockHonoConnection(final Vertx vertx, final ClientConfigProperties props) { final Tracer tracer = NoopTracerFactory.create(); final HonoConnection connection = mock(HonoConnection.class); when(connection.getVertx()).thenReturn(vertx); when(connection.getConfig()).thenReturn(props); when(connection.getTracer()).thenReturn(tracer); when(connection.executeOnContext(VertxMockSupport.anyHandler())).then(invocation -> { final Promise<?> result = Promise.promise(); final Handler<Future<?>> handler = invocation.getArgument(0); handler.handle(result.future()); return result.future(); }); return connection; }
Example #6
Source File: InstrumentationConfig.java From feast with Apache License 2.0 | 5 votes |
@Bean public Tracer tracer() { if (!feastProperties.getTracing().isEnabled()) { return NoopTracerFactory.create(); } if (!feastProperties.getTracing().getTracerName().equalsIgnoreCase("jaeger")) { throw new IllegalArgumentException("Only 'jaeger' tracer is supported for now."); } return io.jaegertracing.Configuration.fromEnv(feastProperties.getTracing().getServiceName()) .getTracer(); }
Example #7
Source File: JdbcDeviceConnectionTenantCleaner.java From enmasse with Apache License 2.0 | 5 votes |
public JdbcDeviceConnectionTenantCleaner() throws Exception { final ObjectMapper mapper = new ObjectMapper(); final JdbcProperties deviceConnection = mapper.readValue(System.getenv("jdbc.deviceConnection"), JdbcProperties.class); this.deviceConnection = new io.enmasse.iot.jdbc.store.devcon.Store( dataSource(this.vertx, deviceConnection), NoopTracerFactory.create(), Store.defaultStatementConfiguration(deviceConnection.getUrl(), ofNullable(deviceConnection.getTableName()))); }
Example #8
Source File: AbstractClientTest.java From java-jaxrs with Apache License 2.0 | 5 votes |
@Override protected void initTracing(ServletContextHandler context) { client.register(new Builder(mockTracer).build()); Tracer serverTracer = NoopTracerFactory.create(); ServerTracingDynamicFeature serverTracingBuilder = new ServerTracingDynamicFeature.Builder(serverTracer) .build(); context.setAttribute(TRACER_ATTRIBUTE, serverTracer); context.setAttribute(CLIENT_ATTRIBUTE, ClientBuilder.newClient()); context.setAttribute(SERVER_TRACING_FEATURE, serverTracingBuilder); }
Example #9
Source File: UsernamePasswordAuthProviderTest.java From hono with Eclipse Public License 2.0 | 5 votes |
/** * Sets up the fixture. */ @BeforeEach public void setUp() { credentialsClient = mock(CredentialsClient.class); credentialsClientFactory = mock(CredentialsClientFactory.class); when(credentialsClientFactory.getOrCreateCredentialsClient("DEFAULT_TENANT")).thenReturn(Future.succeededFuture(credentialsClient)); pwdEncoder = mock(HonoPasswordEncoder.class); when(pwdEncoder.matches(eq("the-secret"), any(JsonObject.class))).thenReturn(true); provider = new UsernamePasswordAuthProvider(credentialsClientFactory, pwdEncoder, new ServiceConfigProperties(), NoopTracerFactory.create()); givenCredentialsOnRecord(CredentialsObject.fromClearTextPassword("4711", "device", "the-secret", null, null)); }
Example #10
Source File: X509AuthProviderTest.java From hono with Eclipse Public License 2.0 | 5 votes |
@BeforeAll static void setUp() { final CredentialsClientFactory credentialsClientFactory = mock(CredentialsClientFactory.class); final ServiceConfigProperties config = new ServiceConfigProperties(); provider = new X509AuthProvider(credentialsClientFactory, config, NoopTracerFactory.create()); }
Example #11
Source File: CredentialsApiAuthProviderTest.java From hono with Eclipse Public License 2.0 | 5 votes |
/** * Verifies that the auth provider fails an authentication request with a 401 * {@code ClientErrorException} if the credentials cannot be parsed. * * @param ctx The vert.x test context. */ @Test public void testAuthenticateFailsWith401ForMalformedCredentials(final VertxTestContext ctx) { // WHEN trying to authenticate using malformed credentials // that do not contain a tenant provider = getProvider(null, NoopTracerFactory.create()); provider.authenticate(new JsonObject(), ctx.failing(t -> { // THEN authentication fails with a 401 client error ctx.verify(() -> assertThat(((ClientErrorException) t).getErrorCode()).isEqualTo(HttpURLConnection.HTTP_UNAUTHORIZED)); ctx.completeNow(); })); }
Example #12
Source File: CredentialsApiAuthProviderTest.java From hono with Eclipse Public License 2.0 | 5 votes |
/** * Sets up the fixture. */ @BeforeEach public void setUp() { credentialsClient = mock(CredentialsClient.class); when(credentialsClient.isOpen()).thenReturn(Boolean.TRUE); credentialsClientFactory = mock(CredentialsClientFactory.class); when(credentialsClientFactory.getOrCreateCredentialsClient(anyString())).thenReturn(Future.succeededFuture(credentialsClient)); provider = getProvider(getDeviceCredentials("type", "TENANT", "user"), NoopTracerFactory.create()); }
Example #13
Source File: HonoBasicAuthHandlerTest.java From hono with Eclipse Public License 2.0 | 5 votes |
/** * Verifies that the handler returns the status code {@link HttpURLConnection#HTTP_BAD_REQUEST} in case of malformed * authorization header. */ @SuppressWarnings({ "unchecked" }) @Test public void testHandleFailsForMalformedAuthorizationHeader() { authHandler = new HonoBasicAuthHandler(authProvider, "test", NoopTracerFactory.create()); final ArgumentCaptor<Throwable> exceptionCaptor = ArgumentCaptor.forClass(Throwable.class); // WHEN trying to authenticate a request using the HTTP BASIC scheme final String authorization = "BASIC test test"; final MultiMap headers = mock(MultiMap.class); when(headers.get(eq(HttpHeaders.AUTHORIZATION))).thenReturn(authorization); final HttpServerRequest req = mock(HttpServerRequest.class); when(req.headers()).thenReturn(headers); final HttpServerResponse resp = mock(HttpServerResponse.class); final RoutingContext ctx = mock(RoutingContext.class); when(ctx.request()).thenReturn(req); when(ctx.response()).thenReturn(resp); when(ctx.currentRoute()).thenReturn(mock(Route.class)); authHandler.parseCredentials(ctx, mock(Handler.class)); // THEN the request context is failed with the 400 error code verify(ctx).fail(exceptionCaptor.capture()); assertThat(exceptionCaptor.getValue()).isInstanceOf(ClientErrorException.class); assertThat(((ClientErrorException) exceptionCaptor.getValue()).getErrorCode()) .isEqualTo(HttpURLConnection.HTTP_BAD_REQUEST); }
Example #14
Source File: HonoBasicAuthHandlerTest.java From hono with Eclipse Public License 2.0 | 5 votes |
/** * Sets up the fixture. */ @BeforeEach public void setUp() { authProvider = mock(AuthProvider.class); authHandler = new HonoBasicAuthHandler(authProvider, "test", NoopTracerFactory.create()) { @Override public void parseCredentials(final RoutingContext context, final Handler<AsyncResult<JsonObject>> handler) { handler.handle(Future.succeededFuture(new JsonObject())); } }; }
Example #15
Source File: ConnectPacketAuthHandlerTest.java From hono with Eclipse Public License 2.0 | 5 votes |
/** * Sets up the fixture. */ @SuppressWarnings("unchecked") @BeforeEach public void setUp() { authProvider = mock(HonoClientBasedAuthProvider.class); authHandler = new ConnectPacketAuthHandler(authProvider, NoopTracerFactory.create()); }
Example #16
Source File: GlobalTracerTestUtil.java From opentracing-java with Apache License 2.0 | 5 votes |
/** * Resets the {@link GlobalTracer} to its initial, unregistered state. */ public static void resetGlobalTracer() { setGlobalTracerUnconditionally(NoopTracerFactory.create()); try { Field isRegisteredField = GlobalTracer.class.getDeclaredField("isRegistered"); isRegisteredField.setAccessible(true); isRegisteredField.set(null, false); isRegisteredField.setAccessible(false); } catch (Exception e) { throw new IllegalStateException("Error reflecting GlobalTracer.tracer: " + e.getMessage(), e); } }
Example #17
Source File: TracingUtil.java From oxd with Apache License 2.0 | 5 votes |
private static Tracer createTracer(OxdServerConfiguration configuration, String componentName) { String tracerName = configuration.getTracer(); if (!configuration.getEnableTracing() || Strings.isNullOrEmpty(tracerName)) { return NoopTracerFactory.create(); } else if ("jaeger".equals(tracerName)) { Configuration.SamplerConfiguration samplerConfig = new Configuration.SamplerConfiguration() .withType(ConstSampler.TYPE) .withParam(1); Configuration.SenderConfiguration senderConfig = new Configuration.SenderConfiguration() .withAgentHost(configuration.getTracerHost()) .withAgentPort(configuration.getTracerPort()); Configuration.ReporterConfiguration reporterConfig = new Configuration.ReporterConfiguration() .withLogSpans(true) .withFlushInterval(1000) .withMaxQueueSize(10000) .withSender(senderConfig); return new Configuration(componentName) .withSampler(samplerConfig) .withReporter(reporterConfig) .getTracer(); } else if ("zipkin".equals(tracerName)) { OkHttpSender sender = OkHttpSender.create( "http://" + configuration.getTracerHost() + ":" + configuration.getTracerPort() + "/api/v1/spans"); Reporter<Span> reporter = AsyncReporter.builder(sender).build(); return BraveTracer.create(Tracing.newBuilder() .localServiceName(componentName) .spanReporter(reporter) .build()); } else { return NoopTracerFactory.create(); } }
Example #18
Source File: ServiceImpersonatorLoadBalancer.java From ja-micro with Apache License 2.0 | 5 votes |
protected HttpClientWrapper createHttpClientWrapper() { int port = locateTargetServicePort(); serviceEndpoint = new ServiceEndpoint(new ScheduledThreadPoolExecutor(1), "localhost:" + port, "", dependencyHealthCheck); HttpClientWrapper retval = new HttpClientWrapper(new ServiceProperties(), createHttpClient(), null, NoopTracerFactory.create()); retval.setLoadBalancer(this); return retval; }
Example #19
Source File: PDFSService.java From dremio-oss with Apache License 2.0 | 5 votes |
@VisibleForTesting public PDFSService( Provider<FabricService> fabricService, Provider<NodeEndpoint> nodeEndpointProvider, Provider<Iterable<NodeEndpoint>> executorsProvider, SabotConfig config, BufferAllocator allocator ) { this(fabricService, nodeEndpointProvider, executorsProvider, NoopTracerFactory.create(), config, allocator, PDFSMode.DATA); }
Example #20
Source File: GlobalTracerTest.java From opentracing-java with Apache License 2.0 | 5 votes |
@Test public void Registering_NoopTracer_indicates_tracer_has_been_registered() { assertThat(GlobalTracer.isRegistered(), is(false)); GlobalTracer.registerIfAbsent(provide(NoopTracerFactory.create())); assertThat(GlobalTracer.isRegistered(), is(true)); }
Example #21
Source File: OpenTracingTracerTest.java From qpid-jms with Apache License 2.0 | 5 votes |
@Test public void testSendOperationsWithoutTracingContextToSend() { // Use the NoOp tracer to ensure there is no context to send Tracer noopTracer = NoopTracerFactory.create(); JmsTracer jmsTracer = new OpenTracingTracer(noopTracer, true); TraceableMessage message = Mockito.mock(TraceableMessage.class); String sendDestination = "myAddress"; String sendOutcomeDescription = "myOutcomeDescription"; // Start send operation jmsTracer.initSend(message, sendDestination); // Should have cleared the tracing annotation, if there was no trace context injected for this send. Mockito.verify(message).removeTracingAnnotation(Mockito.eq(ANNOTATION_KEY)); ArgumentCaptor<Span> sendSpanCapture = ArgumentCaptor.forClass(Span.class); Mockito.verify(message).setTracingContext(Mockito.eq(SEND_SPAN_CONTEXT_KEY), sendSpanCapture.capture()); Mockito.verifyNoMoreInteractions(message); Span sendSpan = sendSpanCapture.getValue(); assertNotNull("expected a span from send operation", sendSpan); Mockito.when(message.getTracingContext(SEND_SPAN_CONTEXT_KEY)).thenReturn(sendSpan); // Finish the send operation jmsTracer.completeSend(message, sendOutcomeDescription); Mockito.verify(message).getTracingContext(Mockito.eq(SEND_SPAN_CONTEXT_KEY)); Mockito.verifyNoMoreInteractions(message); }
Example #22
Source File: Telemetry.java From dremio-oss with Apache License 2.0 | 5 votes |
InnerTelemetryConfigListener(TracerFacade tracerFacade) { rememberedMetrics = configChangeConsumer("metrics", Metrics::onChange); rememberedTracer = configChangeConsumer("tracer", (tracerConf) -> { final Tracer newTracer = tracerConf == null ? NoopTracerFactory.create() : tracerConf.getTracer(); tracerFacade.setTracer(newTracer); }); }
Example #23
Source File: LogTracer.java From carbon-apimgt with Apache License 2.0 | 5 votes |
@Override public Tracer getTracer(String serviceName) { boolean LogEnabled = Boolean.valueOf(configuration.getFirstProperty(TracingConstants.LOG_ENABLED)); if (LogEnabled) { Tracer tracer = NoopTracerFactory.create(); Reporter reporter = new TracingReporter(LogFactory.getLog(TracingConstants.TRACER)); Tracer tracerR = new TracerR(tracer, reporter, new ThreadLocalScopeManager()); GlobalTracer.register(tracerR); return tracerR; } return null; }
Example #24
Source File: WorkItemTest.java From batfish with Apache License 2.0 | 4 votes |
@BeforeClass public static void initTracer() { _mockTracer = new MockTracer(); _noopTracer = NoopTracerFactory.create(); }
Example #25
Source File: TenantServiceImplTest.java From enmasse with Apache License 2.0 | 4 votes |
public TenantServiceImplTest() { this.service = new TenantServiceImpl(); this.service.configuration = new TenantServiceConfigProperties(); this.service.tracer = NoopTracerFactory.create(); }
Example #26
Source File: OpenTracingTracingTest.java From cxf with Apache License 2.0 | 4 votes |
@Override public void tearDown() throws Exception { server.destroy(); GlobalTracer.registerIfAbsent(NoopTracerFactory.create()); }
Example #27
Source File: DefaultRiptideConfigurerTest.java From riptide with MIT License | 4 votes |
@Bean @Primary Tracer primaryTracer() { return NoopTracerFactory.create(); }
Example #28
Source File: DefaultRiptideConfigurerTest.java From riptide with MIT License | 4 votes |
@Bean Tracer secondaryTracer() { return NoopTracerFactory.create(); }
Example #29
Source File: NoopTracingContextTest.java From tchannel-java with MIT License | 4 votes |
@Override protected @NotNull TracingContext tracingContext(@NotNull Tracer tracer) { tracingContext = new OpenTracingContext(NoopTracerFactory.create().scopeManager()); return tracingContext; }
Example #30
Source File: DefaultRiptideConfigurerTest.java From riptide with MIT License | 4 votes |
@Bean Tracer secondaryTracer() { return NoopTracerFactory.create(); }