Instrumentation with Micrometer

EDC provides extensions for instrumentation with the Micrometer metrics library to automatically collect metrics from the host system, JVM, and frameworks and libraries used in EDC (including OkHttp, Jetty, Jersey and ExecutorService).

See sample 04.3 for an example of an instrumented EDC consumer.

Micrometer Extension

This extension provides support for instrumentation for some core EDC components:

Jetty Micrometer Extension

This extension provides support for instrumentation for the Jetty web server, which is enabled when using the JettyExtension.

Jersey Micrometer Extension

This extension provides support for instrumentation for the Jersey framework, which is enabled when using the JerseyExtension.

Instrumenting ExecutorServices

Instrumenting ExecutorServices requires using the ExecutorInstrumentation service to create a wrapper around the service to be instrumented:

ExecutorInstrumentation executorInstrumentation = context.getService(ExecutorInstrumentation.class);

// instrument a ScheduledExecutorService
ScheduledExecutorService executor = executorInstrumentation.instrument(Executors.newScheduledThreadPool(10), "name");

Without any further configuration, a noop implementation of ExecutorInstrumentation is used. We recommend using the implementation provided in the Micrometer Extension that uses Micrometer’s ExecutorServiceMetrics to record ExecutorService metrics.

Configuration

The following properties can use used to configure which metrics will be collected.

  • edc.metrics.enabled: enables/disables metrics collection globally
  • edc.metrics.system.enabled: enables/disables collection of system metrics (class loader, memory, garbage collection, processor and thread metrics)
  • edc.metrics.okhttp.enabled: enables/disables collection of metrics for the OkHttp client
  • edc.metrics.executor.enabled: enables/disables collection of metrics for the instrumented ExecutorServices
  • edc.metrics.jetty.enabled: enables/disables collection of Jetty metrics
  • edc.metrics.jersey.enabled: enables/disables collection of Jersey metrics

Default values are always “true”, switch to “false” to disable the corresponding feature.