JFR in Production Payment Services
bankingDecember 4, 2026

JFR in Production Payment Services

Continuous profiling without leaking secrets

Slow payments are rarely slow all the time. The median card authorisation or instant transfer looks healthy on every dashboard, while one request in a few hundred takes four times as long. That tail is what customers notice, what scheme timeouts punish and what makes an incident hard to diagnose: by the time someone attaches a profiler, the conditions that caused it are gone. Application performance monitoring tools show that a request was slow. They rarely show why: which lock it waited on, which garbage collection paused it, which downstream socket read stalled. 

Java Flight Recorder (JFR), built into the JDK, answers that question with an overhead low enough to leave switched on in production. But a JFR recording is also a data artefact. It travels: attached to incident tickets, sent to vendors, copied to shared drives. By default it can contain the passwords, tokens and keys the service was started with. For a payment service, that brings recordings into the territory of PCI DSS and GDPR. JDK 27 now redacts many of these secrets by default, which is a real improvement. Most banks run JDK 25 LTS, though, and redaction covers only part of the problem. 

This article covers how to run JFR continuously in a payment service, how to instrument each payment step so the tail latency explains itself, and how to keep recordings free of credentials and customer data, on JDK 25 today and with JDK 27's defaults. 


Always on, by design 


JFR is designed to be left running. Its default settings aim for a CPU overhead below one percent, and it records into an in-memory and on-disk ring buffer that keeps only the recent past. A sensible production configuration starts a continuous recording when the JVM starts: 

 1 -XX:StartFlightRecording:name=continuous,settings=default,maxage=30m,maxsize=500m,disk=true 

When an alert fires, the last thirty minutes are already captured, and an operator dumps them without restarting anything: 

 1 jcmd  JFR.dump name=continuous filename=/secure/jfr/payments-$(date +%s).jfr 

JDK 25 also brought three JFR improvements that matter for latency work. Cooperative sampling (JEP 518) makes stack sampling more stable by walking stacks at safepoints while minimising safepoint bias. Experimental CPU-time profiling on Linux (JEP 509) records which methods actually burn CPU, not just which ones happen to be running when sampled. And method timing and tracing (JEP 520) records exact call counts and durations for specific methods you name, which is useful for a targeted investigation, though it carries more overhead than sampling. 


Instrument each payment step with custom events 

Built-in events show what the JVM is doing. Custom events show what the payment is doing, and that's what makes a recording readable by the people who own the service. A small event type, recorded around each step of the payment flow, is enough: 

 1 @Name("com.bank.payments.PaymentStep") 
 2 @Label("Payment Step") 
 3 @Category("Payments") 
 4 @StackTrace(false) 
 5 public class PaymentStepEvent extends Event { 
 6     @Label("Step")     String step;     // e.g. SANCTIONS_SCREEN, LEDGER_POST 
 7     @Label("Rail")     String rail;     // e.g. SEPA_INST, CARD, SWIFT 
 8     @Label("Outcome")  String outcome;  // e.g. OK, DECLINED, TIMEOUT 
 9     @Label("Trace ID") String traceId;  // opaque correlation ID, never an IBAN or PAN 
10 } 

Recording a step costs a few lines, and almost nothing when the event is disabled or below its threshold: 

 1 PaymentStepEvent event = new PaymentStepEvent(); 
 2 event.begin(); 
 3 try { 
 4     ScreeningResult result = sanctions.screen(payment); 
 5     event.outcome = result.code(); 
 6     return result; 
 7 } finally { 
 8     event.end(); 
 9     if (event.shouldCommit()) { 
10         event.step = "SANCTIONS_SCREEN"; 
11         event.rail = payment.rail().name(); 
12         event.traceId = TraceContext.currentId(); 
13         event.commit(); 
14     } 
15 } 

Set a threshold for the event in the recording settings, for example com.bank.payments.PaymentStep#threshold=20 ms. JFR then keeps only the steps that were slow enough to matter. That keeps the volume of events manageable on a service handling thousands of payments per second, and means every recorded step is worth looking at. 


From a slow step to its cause 

The value of JFR comes from correlation. A slow PaymentStep event has a thread and a time window, and JFR's built-in events in the same window usually explain it:

 1 jdk.JavaMonitorEnter and jdk.ThreadPark: the step was waiting on a lock or a connection pool. A shared cache, a synchronised client or an exhausted pool shows up here immediately. 
 2 
 3 jdk.SocketRead: the step was waiting on a downstream system. Its duration, host and port separate "our code is slow" from "the fraud service is slow". 
 4 
 5 jdk.GarbageCollection and jdk.GCPhasePause: the step was paused by the collector, which points at allocation patterns rather than business logic. 
 6 
 7 jdk.VirtualThreadPinned: on services using virtual threads, the step blocked while pinned to its carrier thread, typically inside native code such as some HSM or cryptographic clients. 

The jfr command-line tool covers most first-pass analysis without leaving the terminal. jfr print --events com.bank.payments.PaymentStep lists the slow steps, and jfr view offers prepared summaries such as hot-methods and gc-pauses. JDK Mission Control gives the same data a timeline view, which makes lining up a slow step against a GC pause or lock wait straightforward. 

For the continuous case, the RecordingStream API lets a service consume its own events as they happen. A small component can publish the slow-step rate per rail as a metric, or trigger a dump automatically when the p99 for a step crosses its objective. The evidence is then captured at the moment of the breach rather than when someone notices. 


Where secrets end up in a recording 

JFR records how the process was started, because that context is essential for diagnosis. In practice, a recording typically includes: 

jdk.InitialEnvironmentVariable: every environment variable at startup. In containerised Spring Boot services, that is exactly where database passwords, API keys and signing secrets are usually injected. 

jdk.InitialSystemProperty: every system property, including anything passed as -Dpayment.gateway.token=… or a keystore password. 

jdk.JVMInformation: the full JVM and application command line, including arguments such as --db-password=…. 

On their own these events are harmless. The risk comes from what happens next. Recordings get attached to incident tickets, uploaded to vendor support portals and shared with colleagues, and each copy carries the credentials with it. For a payment service, a file containing a gateway key or database password is a credential exposure, and PCI DSS expects credentials to be protected wherever they are stored. If custom events ever capture card numbers, IBANs or names, the recording also becomes cardholder data or personal data. That brings storage, access, retention and transfer obligations, and potentially every system the file touches into scope. 


What JDK 27 changes 

JDK 27 redacts sensitive data inside the process, before it reaches the recording. With no configuration at all, JFR checks the keys of environment variables and system properties, and the command-line arguments, against a built-in set of case-insensitive patterns covering names like *password*, *secret*, *token* and *api*key*. Matching values appear in the recording as [REDACTED]. 


Two options extend this for application-specific names: 

 1 -XX:FlightRecorderOptions:redact-key=+*signing*,+*hsm*pin*,redact-argument=+--db-password=* 

The + prefix matters. It adds to the built-in patterns. Without it, the list replaces the defaults entirely and silently removes the protection for passwords and tokens. That's an easy mistake to make in a deployment template, and worth a check in configuration review. Patterns can also be loaded from a file, which suits a platform team maintaining one standard list for every payment service. 


What to do on JDK 25 today 

Most production payment services will stay on JDK 25 LTS for some time, so the protection has to come from configuration and process: 

Keep secrets out of the startup context in the first place. Load credentials from mounted secret files or a vault client at runtime, not from environment variables or -D properties. This is the most effective control on any JDK version, and it also removes the exposure in process listings and crash dumps. 


Disable the startup-context events in the continuous recording if secrets can't yet be moved: jdk.InitialEnvironmentVariable#enabled=false and jdk.InitialSystemProperty#enabled=false, set in the recording options or a custom .jfc file. 

Scrub before a file leaves the controlled environment. jfr scrub --exclude-events jdk.InitialEnvironmentVariable,jdk.InitialSystemProperty,jdk.JVMInformation recording.jfr shared.jfr removes those events entirely. Make it a mandatory step in the procedure for sharing recordings with anyone outside the platform team, including vendors. 

Treat recordings as sensitive operational data. Write dumps to a restricted location, limit access to the people who need it, and apply a retention period. 

When the platform moves to JDK 27 or later, in-process redaction becomes a valuable extra layer. It doesn't make the first point optional. 


Custom events are your responsibility 

The JDK's redaction covers the startup context. It doesn't inspect the fields of your own events, and it can't know that a String field holds a card number. Custom event design therefore needs the same discipline as log statements in a payment service: 

Never record PANs, IBANs, names, addresses or authentication data in event fields. Use opaque internal identifiers such as trace IDs or payment IDs that can be resolved only inside the bank's systems. 

Prefer categories to values. Rail, step, outcome and error code tell you why a payment was slow. The customer's identity doesn't. 

Review event types like log formats. New event classes go through the same code review checklist as new logging. A short ArchUnit-style test that checks event field names against a blocklist (pan, iban, cardNumber, name) catches accidents early. 

Keep stack traces off where they add nothing. @StackTrace(false) on high-volume custom events reduces both overhead and the chance of incidental data in recorded frames. 

Designed this way, a recording contains timings, categories and identifiers that mean nothing outside the bank. That's exactly what a vendor or a colleague needs to help diagnose a latency problem, and nothing an attacker or auditor would care about. 


What this adds up to 

JFR gives payment services something APM dashboards don't: the actual cause of a slow request, captured continuously at a cost low enough for production. Custom events per payment step make the recordings readable in business terms, and JDK 25's sampling improvements make the CPU and latency picture more accurate. The same recordings need handling as carefully as any other file that can contain credentials or customer data. JDK 27's default redaction closes the most common leak. Keeping secrets out of the startup context, scrubbing before sharing and designing custom events without customer data close the rest. Engineering the observability in from the start, rather than securing it after a file has already travelled, is how we approach performance work on payment platforms.