open-policy-agent / open-policy-agent/java-opa-sdk
CLI metrics table renders blank cells for counters and histograms
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 16
- Forks
- 24
- Avg merge
- 8h 17m
- Merged PRs (30d)
- 15
Description
MetricsReporter only knows how to render Metrics.Timer. Both table paths in
cli/src/main/java/io/github/open_policy_agent/opa/cli/MetricsReporter.java
test instanceof Metrics.Timer and leave everything else as the empty string:
printSingleMetricsTable(lines 39-43 and 56-61) initialisesString value = ""
and only fills it in for a timer.printStatisticalMetricsTable(line 74) collects values only for timers, so
non-timer metrics are dropped from that table entirely.
Until #216, SimpleMetrics.all() returned only timers, so this was unreachable.
That PR makes all() return counters and histograms too, so a metric registered
via Metrics.counter(...) or Metrics.histogram(...) now reaches the reporter and
prints as a row with a blank cell under TIME.
Nothing in the repo registers a counter or histogram yet, so this is not visible
in normal CLI use today — it only shows up for an embedder that registers one on
the Metrics instance passed to an evaluation. It seemed better as a follow-up
than as scope added to #216.
Suggested fix
Handle the other two types the way MetricsPrinter already does
(opa-evaluator/src/main/java/io/github/open_policy_agent/opa/metrics/MetricsPrinter.java:78-87):
counters print their integer value, histograms explode into one row per stat.
The TIME column header also stops being accurate once non-timers can appear.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in cli/src/main/java/io/github/open_policy_agent/opa/cli/MetricsReporter.java, focusing on printSingleMetricsTable and printStatisticalMetricsTable. Compare their handling with MetricsPrinter at opa-evaluator/src/main/java/io/github/open_policy_agent/opa/metrics/MetricsPrinter.java:78-87; done means counters and histogram statistics render in the CLI tables without an inaccurate TIME-only header.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 78/100