Giter Site home page Giter Site logo

spring-boot-observability's Introduction

Java spring boot app with OpenTelemetry (OTEL) and Grafana (Context) stack

To run OpenTelemetry (OTEL) collector for local and also one to send logs to Context for a Java (Spring Boot) application.

Check Spring Boot app/ directory for more details on the demo app.

OpenTelemetry for Java

There are different ways to collect observability data out of your java applicaion. Refer : https://opentelemetry.io/docs/languages/java/#repositories

We are using the https://github.com/open-telemetry/opentelemetry-java-instrumentation java agent method.

Two stacks in this setup

  • docker-compose.yaml : To run everything(including grafana stack) in local docker environment. Idea is that, this will help you to understand and set up and everything in local correctly before preparing to send it to Context.

Get OpenTelemetry Java Agent

First, download the OpenTelemetry Java agent:

## get latest when possible (test it first, ofcourse)

cd examples/java/spring-boot/etc/
wget -q -O ./opentelemetry-javaagent.jar https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/download/v2.4.0/opentelemetry-javaagent.jar

Build the java app

# Pre-req: you need to have `sdk`: https://sdkman.io/install. 
# Again this is upto you. If you have the correct java runtime already, feel free to move to the build part.
sdk use java 17.0.9-tem # to select correct java runtime

## Build the jar using gradle. You can use maven if you want, then the path to the jar needs to be updated in the Dockerfile
./gradlew bootJar

Run Docker Compose

Next, run the Docker Compose file with the following commands:

For full stack on local

docker compose up --remove-orphans

Stack that sends data to Context

# pre-requisite: needs the context token to be updated in the `etc/otel-collector/config-context.yaml`
docker compose -f docker-compose-context.yaml up --remove-orphans

View otel-collector logs isolated

docker logs otel-collector -f

Endpoints for full local stack

Loki: See Logs

Tempo: See Traces

Prometheus: See Metrics


Cleanup

docker-compose down --remove-orphans

docker volume rm otel_grafana-storage otel_loki-storage otel_mimir-storage otel_minio-data otel_prometheus-data otel_tempo-storage

spring-boot-observability's People

Contributors

vineethvijay7 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.