Giter VIP home page Giter VIP logo

app-observability's Introduction

App Java to test Observability Stack

This is a simple web application, when making an http request, it adds up the number of requests. This application can be used to test the observability stack, targeting the three pillars (Metrics, Tracking and Logs).

Exposed Endpoints

The exposed endpoints in http://localhost:8080/actuator

$ curl localhost:8080/actuator | jq .
{
  "_links": {
    "self": {
      "href": "http://localhost:8080/actuator",
      "templated": false
    },
    "health": {
      "href": "http://localhost:8080/actuator/health",
      "templated": false
    },
    "health-path": {
      "href": "http://localhost:8080/actuator/health/{*path}",
      "templated": true
    },
    "prometheus": {
      "href": "http://localhost:8080/actuator/prometheus",
      "templated": false
    },
    "metrics-requiredMetricName": {
      "href": "http://localhost:8080/actuator/metrics/{requiredMetricName}",
      "templated": true
    },
    "metrics": {
      "href": "http://localhost:8080/actuator/metrics",
      "templated": false
    }
  }
}

http://localhost:8080/actuator - Shows all endpoints exposed
http://localhost:8080/actuator/health - Endpoint to use in probes for health check
http://localhost:8080/actuator/prometheus - Expose application and jvm metrics
http://localhost:8080/actuator/metrics - Expose metrics application

Docker default variables:

ENV OTEL_SDK_DISABLED=true
ENV OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=http://localhost:4318/v1/metrics
ENV OTEL_SERVICE_NAME=app-name
ENV OTEL_INSTRUMENTATION_LIBRARY_NAMES=java.util.logging

OTEL_SDK_DISABLED: (On/Off Switch)
Sets whether the OpenTelemetry SDK is entirely disabled.
Set to true to completely turn off tracing (default).

OTEL_EXPORTER_OTLP_TRACES_ENDPOINT: (URL)
Defines the endpoint URL of the collector where trace data will be sent.
Required if you want to export traces to a collector.

OTEL_SERVICE_NAME: (String)
Identifies your application within the distributed tracing system.
Helps understand which service generated specific traces.

OTEL_INSTRUMENTATION_LIBRARY_NAMES: (Comma-separated list of strings)
Specifies the instrumentation libraries (e.g., Spring Web) that will be enabled for tracing.
Controls which parts of your application are instrumented for trace collection.

Libraries used in the application

spring-boot-starter-web: This is the main dependency for web development with Spring Boot.
pring-boot-starter-actuator: This dependency allows you to expose management endpoints for your Spring Boot application.
micrometer-registry-prometheus: This dependency allows your application to expose metrics (such as number of requests, response time, memory usage) in the Prometheus format.
spring-boot-starter-log4j2: It configures log4j2 for your application, allowing detailed and flexible logging of events during execution.
spring-boot-starter-test: This dependency provides the essential tools for writing unit and integration tests for your Spring Boot application, it includes libraries such as JUnit and Mockito, making it easy to create test scenarios and verify the expected behavior of your application.

Running Application

$ make run-app

Building Application artefact .jar

$ make build-package

Output evidence storage in /app/target/app-v1.0.0.jar

Building Application to Docker

$ make docker IMAGE_NAME=java-app IMAGE_VERSION=v1.0.0

This step build app and docker image.
Set environments to name image (IMAGE_NAME) and tag (IMAGE_VERSION).

Building docker image and pushing to dockerhub

$ make docker-publish IMAGE_NAME=java-app IMAGE_VERSION=v1.0.0

This step build app, docker image and push to https://hub.docker.com.

Cleaning the environment

$ make docker-publish IMAGE_NAME=yourdockerhub/java-app IMAGE_VERSION=v1.0.0

Cleaning target/* java path

Contribute

That's it for now, I hope I can help you test your observability stack.
If you want to contribute, feel free to make the PR or open an Issue.

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.