@Test public void testIsRoot() throws Exception { final StagemonitorPlugin.InitArguments initArguments = mock(StagemonitorPlugin.InitArguments.class); when(initArguments.getMeasurementSession()).thenReturn( new MeasurementSession("JaegerTracerFactoryTest", "test", "test")); final JaegerTracerFactory jaegerTracerFactory = new JaegerTracerFactory(); final Tracer tracer = jaegerTracerFactory.getTracer(initArguments); try (final Scope rootSpan = tracer.buildSpan("foo").startActive(true)) { try (final Scope childSpan = tracer.buildSpan("bar").startActive(true)) { assertThat(jaegerTracerFactory.isRoot(rootSpan.span())).isTrue(); assertThat(jaegerTracerFactory.isRoot(childSpan.span())).isFalse(); } } } }
@Override public void initializePlugin(StagemonitorPlugin.InitArguments initArguments) throws Exception { alertSender = new AlertSender(initArguments.getConfiguration()); CorePlugin corePlugin = initArguments.getPlugin(CorePlugin.class); if (!corePlugin.getElasticsearchUrls().isEmpty()) { incidentRepository = new ElasticsearchIncidentRepository(corePlugin.getElasticsearchClient()); } else { incidentRepository = new ConcurrentMapIncidentRepository(); } logger.info("Using {} for storing incidents.", incidentRepository.getClass().getSimpleName()); thresholdMonitoringReporter = ThresholdMonitoringReporter.forRegistry(initArguments.getMetricRegistry()) .alertingPlugin(this) .alertSender(alertSender) .incidentRepository(incidentRepository) .measurementSession(initArguments.getMeasurementSession()) .build(); thresholdMonitoringReporter.start(checkFrequency.getValue(), TimeUnit.SECONDS); SlaCheckCreatingClassPathScanner.onStart(initArguments.getMeasurementSession()); }
@Override public Tracer getTracer(StagemonitorPlugin.InitArguments initArguments) { final B3TextMapCodec b3TextMapCodec = new B3TextMapCodec.Builder().build(); final JaegerTracer.Builder builder = new JaegerTracer.Builder( initArguments.getMeasurementSession().getApplicationName()) .withReporter(new NoopReporter()) .withSampler(new ConstSampler(true)) .registerInjector(B3HeaderFormat.INSTANCE, b3TextMapCodec) .registerInjector(Format.Builtin.HTTP_HEADERS, b3TextMapCodec) .registerExtractor(Format.Builtin.HTTP_HEADERS, b3TextMapCodec); return builder.build(); }
@Override public void initializePlugin(InitArguments initArguments) { this.metricRegistry = initArguments.getMetricRegistry(); this.healthCheckRegistry = initArguments.getHealthCheckRegistry(); final Integer reloadInterval = getReloadConfigurationInterval(); if (reloadInterval > 0) { initArguments.getConfiguration().scheduleReloadAtRate(reloadInterval, TimeUnit.SECONDS); } initArguments.getMetricRegistry().register(MetricName.name("online").build(), new Gauge<Integer>() { @Override public Integer getValue() { return 1; } }); // it's important to initialize the ElasticsearchClient via getElasticsearchClient() // otherwise the periodic availability check might not get started getElasticsearchClient(); if (isReportToElasticsearch()) { final GrafanaClient grafanaClient = getGrafanaClient(); grafanaClient.createElasticsearchDatasource(getElasticsearchUrl()); grafanaClient.sendGrafanaDashboardAsync("grafana/ElasticsearchCustomMetricsDashboard.json"); } registerReporters(initArguments.getMetricRegistry(), initArguments.getConfiguration(), initArguments.getMeasurementSession()); }
@Override public Tracer getTracer(StagemonitorPlugin.InitArguments initArguments) { final B3TextMapCodec b3TextMapCodec = new B3TextMapCodec.Builder().build(); final JaegerTracer.Builder builder = new JaegerTracer.Builder( initArguments.getMeasurementSession().getApplicationName()) .withReporter(new NoopReporter()) .withSampler(new ConstSampler(true)) .registerInjector(B3HeaderFormat.INSTANCE, b3TextMapCodec) .registerInjector(Format.Builtin.HTTP_HEADERS, b3TextMapCodec) .registerExtractor(Format.Builtin.HTTP_HEADERS, b3TextMapCodec); return builder.build(); }
@Override public Tracer getTracer(StagemonitorPlugin.InitArguments initArguments) { final Tracing braveTracer = Tracing.newBuilder() .localServiceName(initArguments.getMeasurementSession().getApplicationName()) .reporter(getZipkinReporterBuilder(initArguments).build()) .sampler(getSampler()) .build(); return BraveTracer.newBuilder(braveTracer) .textMapPropagation(B3HeaderFormat.INSTANCE, Propagation.B3_STRING) .build(); }