feat(ledger): wire prometheus metrics, otlp tracing and structured json logs - #141
Merged
Conversation
added 4 commits
June 16, 2026 00:46
…on logs Add two bounded ledger counters (ledger.transactions.posted with a post/reversal type tag, ledger.balance.reads) incremented on the success path only, enable the http.server.requests percentile histogram, bridge micrometer tracing to opentelemetry with a configurable otlp endpoint and sampling, and switch console logging to logstash structured json on the default, test and prod profiles while keeping the human-readable pattern in dev. Expose /actuator/prometheus without a token, mirroring health. Closes #51
…structured logs Drop the explicit micrometer 1.13.7 and opentelemetry 1.41.0 pins so the boot bom manages every micrometer and opentelemetry artifact uniformly. The pins left micrometer-registry-prometheus at 1.13.7 while the tracing bridge dragged micrometer-core to 1.15.1, and opentelemetry-api at 1.41.0 against a 1.49.0 sdk, which made the prometheus scrape return 500. Move the structured-log assertion off the flaky OutputCapture path onto Boot StructuredLogEncoder in a unit test.
Spring boot disables metrics export registries in @SpringBootTest by default, so the prometheus registry was absent and /actuator/prometheus returned 500. Add @AutoConfigureObservability so the test context wires the prometheus registry, and drop the diagnostic scrape probe.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Wires generic OSS observability into the ledger service (Epic E-01).
LedgerMetrics-ledger.transactions.posted(tagtype=post|reversal) andledger.balance.reads, incremented on the success path only (after the write + audit commit; failures throw earlier). Enables thehttp.server.requestspercentile histogram. Exposed at/actuator/prometheusasledger_transactions_posted_total/ledger_balance_reads_total(Micrometer appends_total, so the counter names deliberately omit it).${TRACING_SAMPLING_PROBABILITY:0.1}, test disabled).traceId/spanIdflow into the logging MDC via the bridge.logging.structured.format.console=logstashon default/test/prod (one JSON line per event carryingcorrelation_idand trace ids from MDC);devkeeps the human-readable pattern with%X{correlation_id:-}./actuator/prometheusadded toPUBLIC_PATHS(mirrors/actuator/health); exposure stayshealth,info,prometheus.Tagging / cardinality
Only the bounded
typetag is used. No account id, transaction id, amount, actor, or correlation id is ever a metric tag or label. No money value is emitted as a metric.Tests
LedgerMetricsTest(counter names/tags), poster + balance tests assert increment-on-success and no-increment-on-duplicate.ObservabilityIT, CI only): prometheus reachable without a token and contains the posted counter with value >= 1 after a post; a logged line parses as logstash JSON with@timestamp/level/logger_name/message/correlation_id; theTracerbean and tracing properties are bound.MetricsTestConfigsupplies aMeterRegistryto the 5@DataJpaTestslices that import the poster/balance beans (no actuator autoconfig there).Gate chain: analyst, architect, critic (GO-WITH-CHANGES, folded in), code-reviewer (caught the
_totalnaming bug, fixed), security-auditor PASS, OSS-boundary PASS. Local gates green; integration tests run on CI.Closes #51