Skip to content

Spring Boot demo application that generates Java GC activity and logs for monitoring and analysis with OpenObserve.

Notifications You must be signed in to change notification settings

openobserve/java-gc-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Java GC Demo for OpenObserve

A simple Spring Boot application that generates Java GC activity for monitoring with OpenObserve.

Prerequisites

Quick Start

1. Build the Application

git clone https://github.com/openobserve/java-gc-demo.git
cd java-gc-demo
mvn clean package

2. Run with GC Logging Enabled

mkdir -p logs
java '-Xlog:gc*=info:file=logs/gc.log:time,uptime,level,tags:filecount=10,filesize=10M' -jar target/gc-demo-0.0.1-SNAPSHOT.jar

3. Generate GC Activity

Access these endpoints to generate different GC patterns:

  • View memory status: http://localhost:8080/status
  • Allocate persistent memory (leak simulation): http://localhost:8080/allocate?megabytes=20
  • Allocate temporary memory: http://localhost:8080/allocate-temp?megabytes=50
  • Release temporary memory: http://localhost:8080/clear-temp
  • Clear all allocated memory: http://localhost:8080/clear-all

4. Configure OpenTelemetry Collector

Create config.yaml:

receivers:
  filelog:
    include: [ /path/to/your/logs/gc.log ]
    start_at: beginning

processors:
  batch: {}
  resource:
    attributes:
      - key: service.name
        value: "java-gc-demo"
        action: upsert
      - key: app.name
        value: "java-gc-demo"
        action: upsert
      - key: log.type
        value: "gc_log"
        action: upsert
    
exporters:
  otlphttp/openobserve:
    endpoint: https://api.openobserve.ai/api/default
    headers:
      Authorization: Basic <your-api-key>
      stream-name: default

service:
  pipelines:
    logs:
      receivers: [filelog]
      processors: [batch, resource]
      exporters: [otlphttp/openobserve]

Run the collector:

otelcol-contrib --config config.yaml

Learn More

For full details, see our blog post on Java GC logs and OpenObserve.

About

Spring Boot demo application that generates Java GC activity and logs for monitoring and analysis with OpenObserve.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages