com.netflix.spectator.api.DefaultRegistry Java Examples

The following examples show how to use com.netflix.spectator.api.DefaultRegistry. 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: StackdriverWriterTest.java    From kork with Apache License 2.0 6 votes vote down vote up
@Test
public void testAddMeasurementsToTimeSeries() {
  DefaultRegistry testRegistry = new DefaultRegistry(clock);

  long millisA = TimeUnit.MILLISECONDS.convert(1472394975L, TimeUnit.SECONDS);
  long millisB = millisA + 987;
  String timeA = "2016-08-28T14:36:15.000000000Z";
  String timeB = "2016-08-28T14:36:15.987000000Z";
  Meter timerA = testRegistry.timer(idAXY);
  Meter timerB = testRegistry.timer(idBXY);
  Measurement measureAXY = new Measurement(idAXY, millisA, 1);
  Measurement measureBXY = new Measurement(idBXY, millisB, 20.1);

  descriptorRegistrySpy.addExtraTimeSeriesLabel(
      MetricDescriptorCache.INSTANCE_LABEL, INSTANCE_ID);

  Assert.assertEquals(
      makeTimeSeries(descriptorA, idAXY, 1, timeA),
      writer.measurementToTimeSeries(descriptorA.getType(), testRegistry, timerA, measureAXY));
  Assert.assertEquals(
      makeTimeSeries(descriptorB, idBXY, 20.1, timeB),
      writer.measurementToTimeSeries(descriptorB.getType(), testRegistry, timerB, measureBXY));
}
 
Example #2
Source File: CassandraTest.java    From spectator with Apache License 2.0 6 votes vote down vote up
@Test
public void readLatency() throws Exception {
  Registry r = new DefaultRegistry(new ManualClock());
  List<JmxConfig> configs = configs();

  JmxData data = timer("keyspace=test,name=ReadLatency,scope=foo,type=ColumnFamily", 0);
  List<Measurement> ms = measure(r, configs, data);
  Assertions.assertEquals(7, ms.size());
  Assertions.assertEquals(
      50.0e-4,
      Utils.first(ms, "statistic", "percentile_50").value(),
      1e-12);

  data = timer("keyspace=test,name=ReadLatency,scope=foo,type=ColumnFamily", 1);
  ms = measure(r, configs, data);
  Assertions.assertEquals(7, ms.size());
  Assertions.assertEquals(
      50.01e-4,
      Utils.first(ms, "statistic", "percentile_50").value(),
      1e-12);
}
 
Example #3
Source File: SchedulerTest.java    From spectator with Apache License 2.0 6 votes vote down vote up
@Test
public void stopOnFailureTrue() throws Exception {
  Scheduler s = new Scheduler(new DefaultRegistry(), "test", 2);

  Scheduler.Options opts = new Scheduler.Options()
      .withFrequency(Scheduler.Policy.FIXED_DELAY, Duration.ofMillis(10))
      .withStopOnFailure(true);

  final CountDownLatch latch = new CountDownLatch(1);
  ScheduledFuture<?> f = s.schedule(opts, () -> {
    latch.countDown();
    throw new RuntimeException("stop");
  });

  Assertions.assertTrue(latch.await(60, TimeUnit.SECONDS));
  while (!f.isDone()); // This will be an endless loop if broken
  s.shutdown();
}
 
Example #4
Source File: SchedulerTest.java    From spectator with Apache License 2.0 6 votes vote down vote up
@Test
public void stopOnFailureFalse() throws Exception {
  Scheduler s = new Scheduler(new DefaultRegistry(), "test", 2);

  Scheduler.Options opts = new Scheduler.Options()
      .withFrequency(Scheduler.Policy.FIXED_DELAY, Duration.ofMillis(10))
      .withStopOnFailure(false);

  final CountDownLatch latch = new CountDownLatch(5);
  ScheduledFuture<?> f = s.schedule(opts, () -> {
    latch.countDown();
    throw new RuntimeException("stop");
  });

  Assertions.assertTrue(latch.await(60, TimeUnit.SECONDS));
  Assertions.assertFalse(f.isDone());
  s.shutdown();
}
 
Example #5
Source File: SchedulerTest.java    From spectator with Apache License 2.0 6 votes vote down vote up
@Test
public void stopOnFailureFalseThrowable() throws Exception {
  Scheduler s = new Scheduler(new DefaultRegistry(), "test", 1);

  Scheduler.Options opts = new Scheduler.Options()
      .withFrequency(Scheduler.Policy.FIXED_RATE_SKIP_IF_LONG, Duration.ofMillis(10))
      .withStopOnFailure(false);

  final CountDownLatch latch = new CountDownLatch(5);
  ScheduledFuture<?> f = s.schedule(opts, () -> {
    latch.countDown();
    throw new IOError(new RuntimeException("stop"));
  });

  Assertions.assertTrue(latch.await(60, TimeUnit.SECONDS));
  Assertions.assertFalse(f.isDone());
  s.shutdown();
}
 
Example #6
Source File: TitusClientImplTest.java    From titus-control-plane with Apache License 2.0 6 votes vote down vote up
@Before
public void setup() throws IOException {
    final MockJobManagerService mockJobManagerService = new MockJobManagerService();

    testServer = InProcessServerBuilder
            .forName("testServer")
            .directExecutor()
            .addService(mockJobManagerService)
            .build()
            .start();

    final ManagedChannel channel = InProcessChannelBuilder
            .forName("testServer")
            .directExecutor()
            .usePlaintext(true)
            .build();
    final JobManagementServiceStub jobManagementServiceStub = JobManagementServiceGrpc.newStub(channel);
    final JobManagementServiceFutureStub jobManagementServiceFutureStub = JobManagementServiceGrpc.newFutureStub(channel);
    titusClient = new TitusClientImpl(jobManagementServiceStub, jobManagementServiceFutureStub, new DefaultRegistry());
}
 
Example #7
Source File: SchedulerTest.java    From spectator with Apache License 2.0 6 votes vote down vote up
@Test
public void shutdownStopsThreads() throws Exception {
  Scheduler s = new Scheduler(new DefaultRegistry(), "shutdown", 1);

  // Schedule something to force it to start the threads
  Scheduler.Options opts = new Scheduler.Options()
      .withFrequency(Scheduler.Policy.FIXED_RATE_SKIP_IF_LONG, Duration.ofMillis(10))
      .withStopOnFailure(false);
  ScheduledFuture<?> f = s.schedule(opts, () -> {});
  Assertions.assertEquals(1L, numberOfThreads("shutdown"));

  // Shutdown and wait a bit, this gives the thread a chance to restart
  s.shutdown();
  Thread.sleep(300);
  Assertions.assertEquals(0L, numberOfThreads("shutdown"));
}
 
Example #8
Source File: SchedulerTest.java    From spectator with Apache License 2.0 6 votes vote down vote up
@Test
public void updateNextFixedDelay() {
  ManualClock clock = new ManualClock();
  Registry registry = new DefaultRegistry(clock);
  Counter skipped = registry.counter("skipped");

  Scheduler.Options options = new Scheduler.Options()
      .withFrequency(Scheduler.Policy.FIXED_DELAY, Duration.ofSeconds(10));

  clock.setWallTime(5437L);
  Scheduler.DelayedTask task = new Scheduler.DelayedTask(clock, options, () -> {});
  Assertions.assertEquals(5437L, task.getNextExecutionTime());
  Assertions.assertEquals(0L, skipped.count());

  clock.setWallTime(12123L);
  task.updateNextExecutionTime(skipped);
  Assertions.assertEquals(22123L, task.getNextExecutionTime());
  Assertions.assertEquals(0L, skipped.count());

  clock.setWallTime(27000L);
  task.updateNextExecutionTime(skipped);
  Assertions.assertEquals(37000L, task.getNextExecutionTime());
  Assertions.assertEquals(0L, skipped.count());
}
 
Example #9
Source File: BucketTimerTest.java    From spectator with Apache License 2.0 6 votes vote down vote up
@Test
public void basic() {
  Registry r = new DefaultRegistry();
  BucketTimer t = BucketTimer.get(
      r, r.createId("test"), BucketFunctions.latency(4, TimeUnit.SECONDS));

  t.record(3750, TimeUnit.MILLISECONDS);
  Assertions.assertEquals(1, r.timers().count());
  Assertions.assertEquals(1, sum(r, "test"));

  t.record(4221, TimeUnit.MILLISECONDS);
  Assertions.assertEquals(2, r.timers().count());
  Assertions.assertEquals(2, sum(r, "test"));

  t.record(4221, TimeUnit.MILLISECONDS);
  Assertions.assertEquals(2, r.timers().count());
  Assertions.assertEquals(3, sum(r, "test"));
}
 
Example #10
Source File: BucketCounterTest.java    From spectator with Apache License 2.0 6 votes vote down vote up
@Test
public void basic() {
  Registry r = new DefaultRegistry();
  BucketCounter c = BucketCounter.get(
      r, r.createId("test"), BucketFunctions.latency(4, TimeUnit.SECONDS));

  c.record(TimeUnit.MILLISECONDS.toNanos(3750));
  Assertions.assertEquals(1, r.counters().count());
  Assertions.assertEquals(1, sum(r, "test"));

  c.record(TimeUnit.MILLISECONDS.toNanos(4221));
  Assertions.assertEquals(2, r.counters().count());
  Assertions.assertEquals(2, sum(r, "test"));

  c.record(TimeUnit.MILLISECONDS.toNanos(4221));
  Assertions.assertEquals(2, r.counters().count());
  Assertions.assertEquals(3, sum(r, "test"));
}
 
Example #11
Source File: TitusFederationModule.java    From titus-control-plane with Apache License 2.0 6 votes vote down vote up
@Override
protected void configure() {
    bind(Archaius2ConfigurationLogger.class).asEagerSingleton();
    bind(Registry.class).toInstance(new DefaultRegistry());
    bind(SystemLogService.class).to(LoggingSystemLogService.class);
    bind(SystemAbortListener.class).to(LoggingSystemAbortListener.class);

    install(new GovernatorJerseySupportModule());

    install(new ContainerEventBusModule());
    install(new TitusEntitySanitizerModule());

    bind(HostCallerIdResolver.class).to(NoOpHostCallerIdResolver.class);
    bind(CellConnector.class).to(DefaultCellConnector.class);
    bind(CellWebClientConnector.class).to(DefaultCellWebClientConnector.class);
    bind(WebClientFactory.class).toInstance(SimpleWebClientFactory.getInstance());
    bind(CellInfoResolver.class).to(DefaultCellInfoResolver.class);

    install(new FederationEndpointModule());
    install(new ServiceModule());
}
 
Example #12
Source File: BucketDistributionSummaryTest.java    From spectator with Apache License 2.0 6 votes vote down vote up
@Test
public void basic() {
  Registry r = new DefaultRegistry();
  BucketDistributionSummary c = BucketDistributionSummary.get(
      r, r.createId("test"), BucketFunctions.latency(4, TimeUnit.SECONDS));

  c.record(TimeUnit.MILLISECONDS.toNanos(3750));
  Assertions.assertEquals(1, r.distributionSummaries().count());
  Assertions.assertEquals(1, sum(r, "test"));

  c.record(TimeUnit.MILLISECONDS.toNanos(4221));
  Assertions.assertEquals(2, r.distributionSummaries().count());
  Assertions.assertEquals(2, sum(r, "test"));

  c.record(TimeUnit.MILLISECONDS.toNanos(4221));
  Assertions.assertEquals(2, r.distributionSummaries().count());
  Assertions.assertEquals(3, sum(r, "test"));
}
 
Example #13
Source File: PolledMeterTest.java    From spectator with Apache License 2.0 6 votes vote down vote up
@Test
public void removeAndAddRepeatedlyCounter() {
  Registry r = new DefaultRegistry();
  Id id = r.createId("test");

  AtomicLong value = new AtomicLong();
  for (int i = 0; i < 10; ++i) {
    PolledMeter.using(r).withId(id).monitorMonotonicCounter(value);
    PolledMeter.update(r);
    value.incrementAndGet();
    PolledMeter.update(r);
    PolledMeter.remove(r, id);
  }

  Assertions.assertEquals(10, r.counter("test").count());
}
 
Example #14
Source File: ZookeeperLeaderElectorTest.java    From titus-control-plane with Apache License 2.0 6 votes vote down vote up
@Test
public void testConnectionLossWillLeadToStartupFailure() {
    ZookeeperConfiguration config = mock(ZookeeperConfiguration.class);
    when(config.getZkConnectionString()).thenReturn("127.0.0.1:44444");

    ZookeeperClusterResolver clusterResolver = new DefaultZookeeperClusterResolver(config);
    try {
        CuratorServiceImpl cs = closeable.autoCloseable(new CuratorServiceImpl(config, clusterResolver, new DefaultRegistry()), CuratorServiceImpl::shutdown);
        cs.start();

        ZookeeperLeaderElector elector = new ZookeeperLeaderElector(leaderActivator, cs, zkPaths, masterDescription, titusRuntime);
        elector.join();
        fail("The elector should fail fast");
    } catch (IllegalStateException e) {
        assertEquals("The cause should be from ZK connection failure", CuratorConnectionLossException.class, e.getCause().getClass());
        assertTrue("The error message is unexpected: " + e.getMessage(), e.getCause().getMessage().contains("ConnectionLoss"));
    }
}
 
Example #15
Source File: DefaultReconciliationFrameworkTest.java    From titus-control-plane with Apache License 2.0 6 votes vote down vote up
@Test
public void testBootstrapEngineInitialization() {
    InternalReconciliationEngine<SimpleReconcilerEvent> bootstrapEngine = mock(InternalReconciliationEngine.class);
    PublishSubject<SimpleReconcilerEvent> eventSubject = PublishSubject.create();
    when(bootstrapEngine.events()).thenReturn(eventSubject);
    when(bootstrapEngine.triggerActions()).thenReturn(true);
    when(bootstrapEngine.getReferenceView()).thenReturn(EntityHolder.newRoot("myRoot1", "myEntity1"));

    DefaultReconciliationFramework<SimpleReconcilerEvent> framework = new DefaultReconciliationFramework<>(
            Collections.singletonList(bootstrapEngine),
            engineFactory,
            IDLE_TIMEOUT_MS,
            ACTIVE_TIMEOUT_MS,
            indexComparators,
            new DefaultRegistry(),
            Optional.of(testScheduler)
    );
    framework.start();
    AssertableSubscriber<SimpleReconcilerEvent> eventSubscriber = framework.events().test();

    eventSubject.onNext(new SimpleReconcilerEvent(EventType.Changed, "test", Optional.empty()));
    eventSubscriber.assertValueCount(1);
}
 
Example #16
Source File: MetricsControllerTest.java    From spectator with Apache License 2.0 6 votes vote down vote up
@Test
public void testEncodeCombinedRegistry() {
  // Multiple occurrences of measurements in the same registry
  // (confirm these are handled within the registry itself).
  Measurement measureBXY2 = new Measurement(idBXY, 5, 5.5);
  Meter meterB2 = new TestMeter("ignoreB", measureBXY2);

  DefaultRegistry registry = new DefaultRegistry(clock);
  registry.register(meterB);
  registry.register(meterB2);

  List<TaggedDataPoints> expectedTaggedDataPoints = Arrays.asList(
     new TaggedDataPoints(
           Arrays.asList(new BasicTag("tagA", "X"),
                         new BasicTag("tagB", "Y")),
           Arrays.asList(new DataPoint(clock.wallTime(), 50.5 + 5.5))));

  HashMap<String, MetricValues> expect = new HashMap<>();
  expect.put("idB", new MetricValues("Counter", expectedTaggedDataPoints));

  PolledMeter.update(registry);
  Assertions.assertEquals(expect, controller.encodeRegistry(registry, allowAll));
}
 
Example #17
Source File: PolledMeterTest.java    From spectator with Apache License 2.0 5 votes vote down vote up
@Test
public void monitorValueNullPropagate() {
  RegistryConfig config = s -> s.equals("propagateWarnings") ? "true" : null;
  Registry r = new DefaultRegistry(Clock.SYSTEM, config);
  Id id = r.createId("test");

  IllegalArgumentException e = Assertions.assertThrows(
      IllegalArgumentException.class,
      () -> PolledMeter.using(r)
          .withId(id)
          .<Collection<?>>monitorValue(null, Collection::size)
  );
  Assertions.assertTrue(e.getMessage().startsWith("obj is null"));
}
 
Example #18
Source File: PolledMeterTest.java    From spectator with Apache License 2.0 5 votes vote down vote up
@Test
public void monitorMonotonicCounterNullPropagate() {
  RegistryConfig config = s -> s.equals("propagateWarnings") ? "true" : null;
  Registry r = new DefaultRegistry(Clock.SYSTEM, config);
  Id id = r.createId("test");

  AtomicLong v = new AtomicLong(42);
  IllegalArgumentException e = Assertions.assertThrows(
      IllegalArgumentException.class,
      () -> PolledMeter.using(r)
          .withId(id)
          .<AtomicLong>monitorValue(null, n -> v.get())
  );
  Assertions.assertTrue(e.getMessage().startsWith("obj is null"));
}
 
Example #19
Source File: IntervalCounterTest.java    From spectator with Apache License 2.0 5 votes vote down vote up
@Test
public void testInterval() {
  Registry r = new DefaultRegistry(clock);
  Id id = r.createId("test");
  IntervalCounter c = IntervalCounter.get(r, id);
  Assertions.assertEquals(c.secondsSinceLastUpdate(), 0.0, EPSILON);
  clock.setWallTime(1000);
  Assertions.assertEquals(c.secondsSinceLastUpdate(), 1.0, EPSILON);
  c.increment();
  Assertions.assertEquals(c.secondsSinceLastUpdate(), 0.0, EPSILON);
}
 
Example #20
Source File: IntervalCounterTest.java    From spectator with Apache License 2.0 5 votes vote down vote up
@Test
public void testInit() {
  Registry r = new DefaultRegistry(clock);
  clock.setWallTime(42 * 1000L);
  Id id = r.createId("test");
  IntervalCounter c = IntervalCounter.get(r, id);
  Assertions.assertEquals(0L, c.count());
  Assertions.assertEquals(42.0, c.secondsSinceLastUpdate(), EPSILON);
}
 
Example #21
Source File: IpcLogEntryTest.java    From spectator with Apache License 2.0 5 votes vote down vote up
@Test
public void endpointUnknownIfNotSet() {
  Registry registry = new DefaultRegistry();
  IpcLogger logger = new IpcLogger(registry, clock, LoggerFactory.getLogger(getClass()));

  logger.createServerEntry()
      .withOwner("test")
      .markStart()
      .markEnd()
      .log();

  registry.counters().forEach(c -> {
    Assertions.assertEquals("unknown", Utils.getTagValue(c.id(), "ipc.endpoint"));
  });
}
 
Example #22
Source File: IpcLogEntryTest.java    From spectator with Apache License 2.0 5 votes vote down vote up
@Test
public void serverMetricsValidate() {
  Registry registry = new DefaultRegistry();
  IpcLogger logger = new IpcLogger(registry, clock, LoggerFactory.getLogger(getClass()));

  logger.createServerEntry()
      .withOwner("test")
      .markStart()
      .markEnd()
      .log();

  IpcMetric.validate(registry);
}
 
Example #23
Source File: SpectatorAppenderTest.java    From spectator with Apache License 2.0 5 votes vote down vote up
@BeforeEach
public void before() {
  registry = new DefaultRegistry();
  appender = new SpectatorAppender(
      registry, "foo", null, null, false, Property.EMPTY_ARRAY);
  appender.start();
}
 
Example #24
Source File: MetricsControllerTest.java    From spectator with Apache License 2.0 5 votes vote down vote up
@Test
public void testEncodeSimpleRegistry() {
  DefaultRegistry registry = new DefaultRegistry(clock);
  Counter counterA = registry.counter(idAXY);
  Counter counterB = registry.counter(idBXY);
  counterA.increment(4);
  counterB.increment(10);

  List<TaggedDataPoints> expectedTaggedDataPointsA
    = Arrays.asList(
        new TaggedDataPoints(
            Arrays.asList(new BasicTag("tagA", "X"),
                          new BasicTag("tagB", "Y")),
            Arrays.asList(new DataPoint(clock.wallTime(), 4))));

  List<TaggedDataPoints> expectedTaggedDataPointsB
    = Arrays.asList(
        new TaggedDataPoints(
            Arrays.asList(new BasicTag("tagA", "X"),
                          new BasicTag("tagB", "Y")),
            Arrays.asList(new DataPoint(clock.wallTime(), 10))));

  HashMap<String, MetricValues> expect = new HashMap<>();
  expect.put("idA", new MetricValues("Counter", expectedTaggedDataPointsA));
  expect.put("idB", new MetricValues("Counter", expectedTaggedDataPointsB));
  Assertions.assertEquals(expect, controller.encodeRegistry(registry, allowAll));
}
 
Example #25
Source File: IpcLogEntryTest.java    From spectator with Apache License 2.0 5 votes vote down vote up
@Test
public void clientMetricsValidate() {
  Registry registry = new DefaultRegistry();
  IpcLogger logger = new IpcLogger(registry, clock, LoggerFactory.getLogger(getClass()));

  logger.createClientEntry()
      .withOwner("test")
      .markStart()
      .markEnd()
      .log();

  IpcMetric.validate(registry);
}
 
Example #26
Source File: IpcLogEntryTest.java    From spectator with Apache License 2.0 5 votes vote down vote up
@Test
public void inflightRequestsMany() {
  Registry registry = new DefaultRegistry();
  DistributionSummary summary = registry.distributionSummary("ipc.client.inflight");
  IpcLogger logger = new IpcLogger(registry, clock, LoggerFactory.getLogger(getClass()));

  for (int i = 0; i < 10; ++i) {
    logger.createClientEntry().markStart().markEnd();
  }
  Assertions.assertEquals((10 * 11) / 2, summary.totalAmount());
  Assertions.assertEquals(10L, summary.count());
}
 
Example #27
Source File: IpcLogEntryTest.java    From spectator with Apache License 2.0 5 votes vote down vote up
@Test
public void inflightRequests() {
  Registry registry = new DefaultRegistry();
  DistributionSummary summary = registry.distributionSummary("ipc.client.inflight");
  IpcLogger logger = new IpcLogger(registry, clock, LoggerFactory.getLogger(getClass()));
  IpcLogEntry logEntry = logger.createClientEntry();

  Assertions.assertEquals(0L, summary.totalAmount());
  logEntry.markStart();
  Assertions.assertEquals(1L, summary.totalAmount());
  logEntry.markEnd();
  Assertions.assertEquals(1L, summary.totalAmount());
}
 
Example #28
Source File: StackdriverWriterTest.java    From kork with Apache License 2.0 5 votes vote down vote up
@Test
public void writeRegistryWithTimer() throws IOException {
  DefaultRegistry testRegistry = new DefaultRegistry(clock);
  Timer timer = testRegistry.timer(idAXY);
  timer.record(123, TimeUnit.MILLISECONDS);

  // If we get the expected result then we matched the expected descriptors,
  // which means the transforms occurred as expected.
  List<TimeSeries> tsList = writer.registryToTimeSeries(testRegistry);
  Assert.assertEquals(2, tsList.size());
}
 
Example #29
Source File: SchedulerTest.java    From spectator with Apache License 2.0 5 votes vote down vote up
@Test
public void updateNextFixedRateSkip() {
  ManualClock clock = new ManualClock();
  Registry registry = new DefaultRegistry(clock);
  Counter skipped = registry.counter("skipped");

  Scheduler.Options options = new Scheduler.Options()
      .withFrequency(Scheduler.Policy.FIXED_RATE_SKIP_IF_LONG, Duration.ofSeconds(10));

  clock.setWallTime(5437L);
  Scheduler.DelayedTask task = new Scheduler.DelayedTask(clock, options, () -> {});
  Assertions.assertEquals(5437L, task.getNextExecutionTime());
  Assertions.assertEquals(0L, skipped.count());

  clock.setWallTime(12123L);
  task.updateNextExecutionTime(skipped);
  Assertions.assertEquals(15437L, task.getNextExecutionTime());
  Assertions.assertEquals(0L, skipped.count());

  clock.setWallTime(27000L);
  task.updateNextExecutionTime(skipped);
  Assertions.assertEquals(35437L, task.getNextExecutionTime());
  Assertions.assertEquals(1L, skipped.count());

  clock.setWallTime(57000L);
  task.updateNextExecutionTime(skipped);
  Assertions.assertEquals(65437L, task.getNextExecutionTime());
  Assertions.assertEquals(3L, skipped.count());
}
 
Example #30
Source File: ZuulSampleModule.java    From zuul with Apache License 2.0 5 votes vote down vote up
@Override
protected void configure() {
    try {
      ConfigurationManager.loadCascadedPropertiesFromResources("application");
    } catch (Exception ex) {
      throw new RuntimeException("Error loading configuration: " + ex.getMessage(), ex);
    }

    bind(AbstractConfiguration.class).toInstance(ConfigurationManager.getConfigInstance());
    bind(DynamicCodeCompiler.class).to(GroovyCompiler.class);
    bind(FilenameFilter.class).to(GroovyFileFilter.class);

    install(new EurekaModule());

    // sample specific bindings
    bind(BaseServerStartup.class).to(SampleServerStartup.class);

    // use provided basic netty origin manager
    bind(OriginManager.class).to(BasicNettyOriginManager.class);

    // zuul filter loading
    install(new ZuulFiltersModule());
    bind(FilterLoader.class).to(DynamicFilterLoader.class);
    bind(FilterRegistry.class).to(MutableFilterRegistry.class);
    bind(FilterFileManager.class).asEagerSingleton();


    // general server bindings
    bind(ServerStatusManager.class); // health/discovery status
    bind(SessionContextDecorator.class).to(ZuulSessionContextDecorator.class); // decorate new sessions when requests come in
    bind(Registry.class).to(DefaultRegistry.class); // atlas metrics registry
    bind(RequestCompleteHandler.class).to(BasicRequestCompleteHandler.class); // metrics post-request completion
    bind(RequestMetricsPublisher.class).to(BasicRequestMetricsPublisher.class); // timings publisher

    // access logger, including request ID generator
    bind(AccessLogPublisher.class).toInstance(new AccessLogPublisher("ACCESS",
            (channel, httpRequest) -> ClientRequestReceiver.getRequestFromChannel(channel).getContext().getUUID()));
}