Tabnine Logo
MeasurementSession.<init>
Code IndexAdd Tabnine to your IDE (free)

How to use
org.stagemonitor.core.MeasurementSession
constructor

Best Java code snippets using org.stagemonitor.core.MeasurementSession.<init> (Showing top 20 results out of 315)

origin: stagemonitor/stagemonitor

public Incident sendTestAlert(Subscription subscription, CheckResult.Status status) {
  Check check = new Check();
  check.setName("Test Check");
  check.setApplication("testApp");
  check.setTarget(name("test").build());
  check.getWarn().add(new Threshold("mean", Threshold.Operator.GREATER_EQUAL, 1));
  Incident testIncident = new Incident(check, new MeasurementSession("testApp", "testHost", "testInstance"),
      Arrays.asList(new CheckResult("test", 10, status)));
  tryAlert(testIncident, subscription, alerterByType.get(subscription.getAlerterType()));
  return testIncident;
}
origin: stagemonitor/stagemonitor

@Before
public void setUp() throws Exception {
  registry = new Metric2Registry();
  final ConfigurationRegistry configuration = Mockito.mock(ConfigurationRegistry.class);
  final CorePlugin corePlugin = mock(CorePlugin.class);
  when(corePlugin.isReportToJMX()).thenReturn(true);
  when(configuration.getConfig(CorePlugin.class)).thenReturn(corePlugin);
  new CorePlugin(mock(ElasticsearchClient.class)).registerReporters(registry, configuration, new MeasurementSession("JmxReportingTest", "test", "test"));
}
origin: stagemonitor/stagemonitor

@Test
public void testDisabledPlugin() throws Exception {
  when(corePlugin.isStagemonitorActive()).thenReturn(true);
  when(corePlugin.getDisabledPlugins()).thenReturn(Collections.singletonList("TestExceptionPlugin"));
  Stagemonitor.reset(new MeasurementSession("StagemonitorTest", "testHost", "testInstance"));
  assertThat(healthCheckRegistry.runHealthCheck("TestPlugin").isHealthy()).isTrue();
  assertThat(healthCheckRegistry.runHealthCheck("TestExceptionPlugin").isHealthy()).isFalse();
  assertThat(healthCheckRegistry.runHealthCheck("TestExceptionPlugin").getMessage()).isEqualTo("disabled via configuration");
}
origin: stagemonitor/stagemonitor

@Test
public void testMDCStagemonitorDeactivated() throws Exception {
  when(corePlugin.isStagemonitorActive()).thenReturn(false);
  when(corePlugin.getMeasurementSession())
      .thenReturn(new MeasurementSession("MDCSpanEventListenerTest", "testHost", null));
  mdcSpanInterceptor.onStart(spanWrapper);
  assertNull(MDC.getCopyOfContextMap());
}
origin: stagemonitor/stagemonitor

@Test
public void testNotInitialized() throws Exception {
  when(corePlugin.isStagemonitorActive()).thenReturn(true);
  final MeasurementSession measurementSession = new MeasurementSession(null, "testHost", "testInstance");
  Stagemonitor.reset(measurementSession);
  assertFalse(Stagemonitor.isStarted());
}
origin: stagemonitor/stagemonitor

@BeforeClass
public static void attachProfiler() throws Exception {
  GlobalTracerTestHelper.resetGlobalTracer();
  Stagemonitor.reset(new MeasurementSession("ConnectionMonitoringTransformerTest", "test", "test"));
}
origin: stagemonitor/stagemonitor

@Before
public void setUp() throws Exception {
  alertingPlugin = mock(AlertingPlugin.class);
  ConcurrentMapIncidentRepository incidentRepository = new ConcurrentMapIncidentRepository();
  incident = new Incident(ThresholdMonitoringReporterTest.createCheckCheckingMean(1, 5),
      new MeasurementSession("testApp", "testHost2", "testInstance"),
      Arrays.asList(new CheckResult("test", 10, CheckResult.Status.CRITICAL),
          new CheckResult("test", 10, CheckResult.Status.ERROR)));
  incidentRepository.createIncident(incident);
  when(alertingPlugin.getIncidentRepository()).thenReturn(incidentRepository);
  incidentServlet = new IncidentServlet(alertingPlugin);
}
origin: stagemonitor/stagemonitor

public static Incident createIncidentWithVersion(String checkId, int version) {
  Incident incident = new Incident(ThresholdMonitoringReporterTest.createCheckCheckingMean(1, 5),
      new MeasurementSession("testApp", "testHost2", "testInstance"),
      Arrays.asList(new CheckResult("test", 10, CheckResult.Status.CRITICAL),
          new CheckResult("test", 10, CheckResult.Status.ERROR)));
  incident.setVersion(version);
  incident.setCheckId(checkId);
  return incident;
}
origin: stagemonitor/stagemonitor

  @Test
  public void testCreateAndGetIncindent() throws Exception {
    final Check check = ThresholdMonitoringReporterTest.createCheckCheckingMean(1, 5);
    check.setId("test 1");
    final Incident incident = new Incident(check,
        new MeasurementSession("testApp", "testHost2", "testInstance"),
        Arrays.asList(new CheckResult("test", 10, CheckResult.Status.CRITICAL),
            new CheckResult("test", 10, CheckResult.Status.ERROR)));
    elasticsearchIncidentRepository.createIncident(incident);
    refresh();
    assertThat(elasticsearchIncidentRepository.getIncidentByCheckId("test 1")).isEqualTo(incident);
  }
}
origin: stagemonitor/stagemonitor

@Before
public void before() throws Exception {
  Stagemonitor.reset(new MeasurementSession("JaxRsRequestNameDeterminerTransformerTest", "testHost", "testInstance"));
  registry.removeMatching(Metric2Filter.ALL);
  when(configuration.getConfig(TracingPlugin.class)).thenReturn(tracingPlugin);
origin: stagemonitor/stagemonitor

  @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();
      }
    }
  }
}
origin: stagemonitor/stagemonitor

/**
 * Should only be used outside of this class by the internal unit tests
 */
@Deprecated
public static void reset(MeasurementSession measurementSession) {
  started = false;
  disabled = false;
  if (configuration == null) {
    reloadPluginsAndConfiguration();
  }
  if (measurementSession == null) {
    CorePlugin corePlugin = getPlugin(CorePlugin.class);
    measurementSession = new MeasurementSession(corePlugin.getApplicationName(),
        corePlugin.getHostName(), corePlugin.getInstanceName());
  }
  onShutdownActions.add(AgentAttacher.performRuntimeAttachment());
  startMonitoring(measurementSession);
  healthCheckRegistry.register("Startup", new HealthCheck() {
    @Override
    protected Result check() throws Exception {
      if (started) {
        return Result.healthy();
      } else {
        return Result.unhealthy("stagemonitor is not started");
      }
    }
  });
  logStatus();
  new ConfigurationLogger().logConfiguration(configuration);
}
origin: stagemonitor/stagemonitor

@Test
public void testMdc() throws Exception {
  Stagemonitor.reset(new MeasurementSession("MDCSpanEventListenerTest", "testHost", "testInstance"));
  when(corePlugin.getMeasurementSession())
      .thenReturn(new MeasurementSession("MDCSpanEventListenerTest", "testHost", "testInstance"));
  mdcSpanInterceptor.onStart(spanWrapper);
  assertNotNull(MDC.get("spanId"));
  assertNotNull(MDC.get("traceId"));
  assertNull(MDC.get("parentId"));
  mdcSpanInterceptor.onFinish(spanWrapper, null, 0);
  assertThat(MDC.getCopyOfContextMap()).isEmpty();
}
origin: stagemonitor/stagemonitor

    TagRecordingSpanEventListener.asList(tags),
    samplePriorityDeterminingSpanInterceptor, reportingSpanEventListener);
when(corePlugin.getMeasurementSession()).thenReturn(new MeasurementSession(getClass().getSimpleName(), "test", "test"));
when(tracingPlugin.getTracer()).then((invocation) -> {
  if (corePlugin.isStagemonitorActive()) {
origin: stagemonitor/stagemonitor

@Test
public void testStartMonitoring() throws Exception {
  when(corePlugin.isStagemonitorActive()).thenReturn(true);
  Stagemonitor.setConfiguration(configuration);
  Stagemonitor.reset();
  final MeasurementSession measurementSession = new MeasurementSession("StagemonitorTest", "testHost", "testInstance");
  Stagemonitor.reset(measurementSession);
  assertTrue(Stagemonitor.isStarted());
  assertTrue(Stagemonitor.getMeasurementSession().isInitialized());
  assertSame(measurementSession, Stagemonitor.getMeasurementSession());
  assertThat(healthCheckRegistry.runHealthCheck("TestPlugin").isHealthy()).isTrue();
  assertThat(healthCheckRegistry.runHealthCheck("TestExceptionPlugin").isHealthy()).isFalse();
}
origin: stagemonitor/stagemonitor

@Test
public void testStartMonitoringNotActive() throws Exception {
  when(corePlugin.isStagemonitorActive()).thenReturn(false);
  final MeasurementSession measurementSession = new MeasurementSession("StagemonitorTest", "testHost", "testInstance");
  Stagemonitor.reset(measurementSession);
  assertTrue(Stagemonitor.isDisabled());
  assertFalse(Stagemonitor.isStarted());
  assertTrue(Stagemonitor.getMeasurementSession().isInitialized());
  assertThat(healthCheckRegistry.getNames()).doesNotContain("TestPlugin", "TestExceptionPlugin");
}
origin: stagemonitor/stagemonitor

when(alertingPlugin.getChecks()).thenReturn(Collections.singletonMap(check.getId(), check));
incidentRepository.createIncident(
    new Incident(check, new MeasurementSession("testApp", "testHost2", "testInstance"),
        Arrays.asList(new CheckResult("test", 10, CheckResult.Status.CRITICAL))));
origin: stagemonitor/stagemonitor

@Test
public void testMdcStagemonitorNotStarted() throws Exception {
  final MeasurementSession measurementSession = new MeasurementSession("MDCSpanEventListenerTest", "testHost", null);
  Stagemonitor.reset(measurementSession);
  when(corePlugin.getMeasurementSession()).thenReturn(measurementSession);
  mdcSpanInterceptor.onStart(spanWrapper);
  assertEquals("testHost", MDC.get("host"));
  assertEquals("MDCSpanEventListenerTest", MDC.get("application"));
  assertNull(MDC.get("instance"));
  assertNull(MDC.get("spanId"));
  assertNull(MDC.get("traceId"));
  assertNull(MDC.get("parentId"));
  mdcSpanInterceptor.onFinish(spanWrapper, null, 0);
}
origin: stagemonitor/stagemonitor

@Before
public void before() throws Exception {
  GlobalTracerTestHelper.resetGlobalTracer();
  testClass = new TestSubClass();
  metricRegistry = Stagemonitor.getMetric2Registry();
  testClassLevelAnnotationClass = new TestClassLevelAnnotationClass();
  metricRegistry.removeMatching(Metric2Filter.ALL);
  Stagemonitor.reset(new MeasurementSession("TracedTransformerTest", "test", "test"));
  spanCapturingReporter = new SpanCapturingReporter();
  tags = new HashMap<>();
  Stagemonitor.getPlugin(TracingPlugin.class).addSpanEventListenerFactory(new TagRecordingSpanEventListener(tags));
  Stagemonitor.getPlugin(TracingPlugin.class).addReporter(spanCapturingReporter);
  assertThat(GlobalTracer.get().scopeManager().active()).isNull();
}
origin: stagemonitor/stagemonitor

  @Test
  public void testToJson() throws Exception {
    MeasurementSession measurementSession = new MeasurementSession("app", "host", "instance");
    final MeasurementSession jsonSession = JsonUtils.getMapper().readValue(JsonUtils.toJson(measurementSession), MeasurementSession.class);
    assertEquals(measurementSession.getApplicationName(), jsonSession.getApplicationName());
    assertEquals(measurementSession.getHostName(), jsonSession.getHostName());
    assertEquals(measurementSession.getInstanceName(), jsonSession.getInstanceName());
    assertEquals(measurementSession.getInstanceName(), jsonSession.getInstanceName());
    assertEquals(measurementSession.getId(), jsonSession.getId());
    assertEquals(measurementSession.getStart(), jsonSession.getStart());
  }
}
org.stagemonitor.coreMeasurementSession<init>

Popular methods of MeasurementSession

  • getApplicationName
  • getHostName
  • getInstanceName
  • asMap
  • getId
  • getStartTimestamp
  • isInitialized
  • getEndTimestamp
  • getStart
  • isNull
  • setEndTimestamp
  • setEndTimestamp

Popular in Java

  • Making http post requests using okhttp
  • getSystemService (Context)
  • findViewById (Activity)
  • notifyDataSetChanged (ArrayAdapter)
  • Point (java.awt)
    A point representing a location in (x,y) coordinate space, specified in integer precision.
  • Collection (java.util)
    Collection is the root of the collection hierarchy. It defines operations on data collections and t
  • List (java.util)
    An ordered collection (also known as a sequence). The user of this interface has precise control ove
  • PriorityQueue (java.util)
    A PriorityQueue holds elements on a priority heap, which orders the elements according to their natu
  • CountDownLatch (java.util.concurrent)
    A synchronization aid that allows one or more threads to wait until a set of operations being perfor
  • ServletException (javax.servlet)
    Defines a general exception a servlet can throw when it encounters difficulty.
  • Top plugins for WebStorm
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now