Skip to content

No okapi.metrics.enabled flag: okapi.metrics.enabled=false is silently ignored #92

Description

@endrju19

OkapiMicrometerAutoConfiguration has no property-level opt-out, and the flag a user would naturally reach for is silently ignored.

Current state

OkapiMetricsProperties (OkapiMetricsProperties.kt:14-16) exposes only refreshInterval:

@ConfigurationProperties(prefix = "okapi.metrics")
data class OkapiMetricsProperties(
    val refreshInterval: Duration = Duration.ofSeconds(15),
)

and OkapiMicrometerAutoConfiguration carries no @ConditionalOnProperty. Because ignoreUnknownFields defaults to true, setting okapi.metrics.enabled=false binds nothing, raises nothing, and changes nothing:

--okapi.metrics.enabled=false  → context starts, TOTAL okapi_* series: 12   (unchanged)

The only mechanism that works is excluding the whole auto-configuration:

--spring.autoconfigure.exclude=com.softwaremill.okapi.springboot.OkapiMicrometerAutoConfiguration  → 0 series

Both verified on v1.0.0 (e199775).

Why it matters

This is inconsistent with the rest of the library, which offers okapi.processor.enabled, okapi.purger.enabled and okapi.liquibase.enabled. A user who sets okapi.metrics.enabled=false gets no feedback and will reasonably believe metrics are off, while OutboxMetricsRefresher keeps its daemon thread and keeps issuing two store queries every refreshInterval (15s by default).

Wanting to stop the gauge polling without dropping okapi-micrometer entirely is a realistic need — reducing database load, quieting things during an incident, or a publish-only/worker deployment that still wants the delivery counters.

The severity is low; the silent-ignore is the annoying part, not the polling itself.

Possible directions

Add okapi.metrics.enabled as a @ConditionalOnProperty on the bean factory (matching how processor/purger/liquibase do it, per the convention that enabled is a condition rather than a field in the *Properties class). A narrower alternative would be a flag that stops only the refresher, keeping the counters registered by MicrometerOutboxListener.

Either way, documenting the existing spring.autoconfigure.exclude route in the README would help — none of the .enabled opt-outs are currently mentioned there.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions