Skip to content

Profiling/pretty printer - #43

Merged
johanfylling merged 4 commits into
open-policy-agent:mainfrom
johanfylling:profiling/pretty_printer
Jun 14, 2026
Merged

Profiling/pretty printer#43
johanfylling merged 4 commits into
open-policy-agent:mainfrom
johanfylling:profiling/pretty_printer

Conversation

@johanfylling

Copy link
Copy Markdown
Contributor

Adding a metrics pretty-printer replicating the opa eval --metrics --format pretty output

Engine engine = new Engine.Builder()
    .withBundleLoader(new TarballBundleLoader("authz",
        Path.of("bundles/authz.tar.gz")))
    .build();

SimpleMetrics metrics = new SimpleMetrics();

Engine.PreparedQuery pq = engine.prepareForEvaluation()
    .withMetrics(metrics)
    .build();

boolean allowed = query.eval(input, Boolean.class);

System.out.println(MetricsPrinter.metricsToString(metrics));

Signed-off-by: Johan Fylling <johan.dev@fylling.se>
Signed-off-by: Johan Fylling <johan.dev@fylling.se>
Signed-off-by: Johan Fylling <johan.dev@fylling.se>
Signed-off-by: Johan Fylling <johan.dev@fylling.se>
@johanfylling
johanfylling force-pushed the profiling/pretty_printer branch from 2c5f5f5 to f6a5420 Compare June 4, 2026 10:48

class MetricsModuleTest {

// Mirrors a real consumer: JavaTimeModule is required for Jackson to handle Duration; the

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe mention this new requirement in the readme?

@johanfylling
johanfylling merged commit 996eb05 into open-policy-agent:main Jun 14, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants