A java flight recording helper

Overview

FlightMemory

A java flight recording helper

Helper class for production profiling using java flight recorder (JFR)

FlightMemory.recordingAsZip(Duration.ofSeconds(10));

Returns a CompletableFuture<InputStream> to a zipfile which contains:

  • profile-XXX.jfr
  • stacks-XXX.folded
  • _coroutinesDump.txt
    • A kotlin coroutines dump. Debug probes must be installed beforehand (at start), with DebugProbes.install() available in . If debug probes are not installed the file is empty.

Requires the app to run in a JVM with flight recorder classes available (jdk.jfr package), for example java8u262 or higher (jdk not jre) or java11

Depend on it in gradle or maven

repositories {
    ...
    maven { url 'https://jitpack.io' }
}
implementation 'com.github.rrva:flightmemory:0.1.0'

Example usage in a spring boot application:

Here we do a ten second profiling, so we record and return the recording synchronously. For long recordings you might get a HTTP timeout so it might be better to return immediately with a link where the finished recording can be fetched.

Java usage:

import org.springframework.core.io.InputStreamResource;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import io.github.rrva.flightmemory.FlightMemory;
import java.time.LocalDateTime;
import java.time.Duration;
import java.util.concurrent.ExecutionException;


@RestController
public class FlightRecordingController {

    @GetMapping("/profile.jfr.zip")
    public ResponseEntity<InputStreamResource> flightRecorder() throws ExecutionException, InterruptedException {
        LocalDateTime now = LocalDateTime.now();
        InputStreamResource inputStreamResource = 
                new InputStreamResource(FlightMemory.recordingAsZip(Duration.ofSeconds(10)).get());
        HttpHeaders httpHeaders = new HttpHeaders();
        httpHeaders.setContentType(MediaType.APPLICATION_OCTET_STREAM);

        httpHeaders.set("Content-Disposition", "attachment; filename=index-profile-"+now+".zip");

        return new ResponseEntity<InputStreamResource>(inputStreamResource, httpHeaders, HttpStatus.OK);
    }
}
You might also like...
Hexagonal Architecture Java Example
Hexagonal Architecture Java Example

Hexagonal Architecture Dev.to Hexagonal Architecture Article I have been working on many projects that claim to be using the Hexagonal Architecture St

A generic library for quick development in Spring Boot using Java Generics.
A generic library for quick development in Spring Boot using Java Generics.

slinky Now in Kotlin! A generic library for quick development in Spring Boot using Java Generics. Why "slinky"? A slinky is a precompressed helical sp

This project uses Quarkus, the Supersonic Subatomic Java Framework

api Project This project uses Quarkus, the Supersonic Subatomic Java Framework.

A sample project to debunk common misbeliefs regarding the impact the Log4j vulnerabilities on Java Applications
A sample project to debunk common misbeliefs regarding the impact the Log4j vulnerabilities on Java Applications

Introduction This project intends to debunk two common misbeliefs regarding the

Plannr is an organizational platform developed using Java, in the form of an Android app, that helps university students coordinate their everyday routine.
Plannr is an organizational platform developed using Java, in the form of an Android app, that helps university students coordinate their everyday routine.

Plannr Plannr is an organizational platform developed using Java, in the form of an Android app, that helps university students coordinate their every

GraphQL Jetpack - A collection of packages for easily writing Java GraphQL server implementations

GraphQL Jetpack A collection of packages for easily writing Java GraphQL server

🌱 A test implementation of a Minecraft server using RESTful API taking advantage of the interoperability between Kotlin and Java.

🌱 Norin A test implementation of a Minecraft server using RESTful API taking advantage of the interoperability between Kotlin and Java. This project

Kbackend - A simple backend library for creating backends in Kotlin/Java

kbackend A simple backend library for creating backends in Kotlin/Java Setup Thi

Spring-graphql-getting-started - Spring for GraphQL provides support for Spring applications built on GraphQL Java

Getting Started with GraphQL and Spring Boot Spring for GraphQL provides support

Releases(0.1.3)
Owner
Ragnar Rova
Ragnar Rova
Helper functions for making Approvals-Java more Kotlin friendly

Approvals-Kt Helper functions for making Approvals-Java more Kotlin-friendly Usage Verify using Approvals-Kt import com.github.greghynds.approvals.Kot

Greg Hynds 2 Oct 18, 2021
Comparison among Java, Groovy, Scala, Kotlin in Android Development.

中文版 日本語 AndroidDemoIn4Languages A simple Android application written in Java, Groovy, Scala and Kotlin in order to find out what is the better languag

Sidney Xu 196 Nov 11, 2022
Archimedes's implementation for the Java Virtual Machine (JVM)

Archimedes Give me a place to stand, and I shall move the earth. Archimedes's implementation for the Java Virtual Machine (JVM) Building From Source T

Archimedes 24 Aug 20, 2022
An example project for configuring Rust with Java 18's Panama/jextract

rust-panama A template project for setting up both Rust and the Java 18 Panama Foreign Linker API (via jextract). How to Setup Clone the repo. Modify

Aidan 14 Jul 5, 2022
🧚‍♀️ Java library to interact with YouTrack's REST API.

YouTrack Kotlin API ??‍ Kotlin JVM library to interact with YouTrack's REST API. Usage fun main(args: Array<String>) { val youtrack = YouTrack {

Noel 2 Oct 1, 2021
Kotlin & Java class for gRPC client

jvm-minter-grpc-class Kotlin & Java class for gRPC client Use @TODO Разное Добавление git subtree add --prefix node-grpc-gateway https://github.com/Mi

Aleksey Kukhnovets 2 May 26, 2022
This project uses Quarkus, the Supersonic Subatomic Java Framework.

foodhouse Project This project uses Quarkus, the Supersonic Subatomic Java Framework. If you want to learn more about Quarkus, please visit its websit

null 0 Nov 29, 2021
GraphQL for Java with Spring Boot made easy.

GraphQL for Java with Spring Boot made easy.

Netflix, Inc. 2.5k Jan 9, 2023
Kotlin dropwizard app running on Java 11. With Guice injection loaded.

hello world How to start the hello world application Run mvn clean install to build your application Start application with java -jar target/dropwizar

null 0 Nov 24, 2021
A Kotlin/Java library to connect directly to an Android device without an adb binary or an ADB server

dadb Blog Post: Our First Open-Source Project A Kotlin/Java library to connect directly to an Android device without an adb binary or an ADB server de

mobile.dev 791 Dec 20, 2022