diff --git a/README.md b/README.md index 808778b..f76cb9f 100644 --- a/README.md +++ b/README.md @@ -114,6 +114,12 @@ With Spring Boot Actuator and a Prometheus registry (`micrometer-registry-promet | `okapi.entries.count` | Gauge | Current entry count (tag: `status=pending\|delivered\|failed`) | | `okapi.entries.lag.seconds` | Gauge | Age of oldest entry in seconds (tag: `status`) | +### Configuration + +| Property | Default | Description | +|----------|---------|-------------| +| `okapi.metrics.refresh-interval` | `PT15S` (15s) | How often gauge metrics poll the outbox store. Each refresh runs one transaction with two queries. | + ### Multi-instance deployments Counters and timers (`okapi.entries.delivered`, `okapi.entries.retry.scheduled`, `okapi.entries.failed`, `okapi.batch.duration`) report work performed by **each instance** — aggregate with `sum`: diff --git a/okapi-micrometer/build.gradle.kts b/okapi-micrometer/build.gradle.kts index 98b7b3d..3129f29 100644 --- a/okapi-micrometer/build.gradle.kts +++ b/okapi-micrometer/build.gradle.kts @@ -1,5 +1,6 @@ plugins { id("buildsrc.convention.kotlin-jvm") + id("buildsrc.convention.publish") } dependencies { diff --git a/okapi-spring-boot/src/main/kotlin/com/softwaremill/okapi/springboot/OkapiMetricsProperties.kt b/okapi-spring-boot/src/main/kotlin/com/softwaremill/okapi/springboot/OkapiMetricsProperties.kt index ac354cd..e532790 100644 --- a/okapi-spring-boot/src/main/kotlin/com/softwaremill/okapi/springboot/OkapiMetricsProperties.kt +++ b/okapi-spring-boot/src/main/kotlin/com/softwaremill/okapi/springboot/OkapiMetricsProperties.kt @@ -3,6 +3,13 @@ package com.softwaremill.okapi.springboot import org.springframework.boot.context.properties.ConfigurationProperties import java.time.Duration +/** + * Configuration for Okapi Micrometer metrics. + * + * @property refreshInterval How often gauge metrics (`okapi.entries.count`, `okapi.entries.lag.seconds`) + * are refreshed from the outbox store. Each refresh runs one transaction with two queries. + * Set under property `okapi.metrics.refresh-interval`, e.g. `PT15S`, `30s`, `1m`. Default: 15 seconds. + */ @ConfigurationProperties(prefix = "okapi.metrics") data class OkapiMetricsProperties( val refreshInterval: Duration = Duration.ofSeconds(15), diff --git a/okapi-spring-boot/src/main/resources/META-INF/spring-configuration-metadata.json b/okapi-spring-boot/src/main/resources/META-INF/spring-configuration-metadata.json index 6361630..0e18021 100644 --- a/okapi-spring-boot/src/main/resources/META-INF/spring-configuration-metadata.json +++ b/okapi-spring-boot/src/main/resources/META-INF/spring-configuration-metadata.json @@ -14,6 +14,11 @@ "name": "okapi.processor", "type": "com.softwaremill.okapi.springboot.OutboxProcessorProperties", "description": "Outbox processor configuration." + }, + { + "name": "okapi.metrics", + "type": "com.softwaremill.okapi.springboot.OkapiMetricsProperties", + "description": "Okapi Micrometer metrics configuration (okapi-micrometer module)." } ], "properties": [ @@ -70,6 +75,12 @@ "type": "java.lang.String", "defaultValue": null, "description": "Name of the DataSource bean to use for the outbox. When set, okapi uses this specific DataSource instead of the primary one. Required in multi-datasource setups where the outbox table is not in the primary database." + }, + { + "name": "okapi.metrics.refresh-interval", + "type": "java.time.Duration", + "defaultValue": "15s", + "description": "How often gauge metrics (okapi.entries.count, okapi.entries.lag.seconds) are refreshed from the outbox store. Each refresh runs one transaction with two queries. Requires okapi-micrometer on the classpath." } ] }