top of page

SpringbootApp Tracing with OpenTelementary +Zipkin+Jaeger+Grafna+prometheus

  • Writer: Anand Nerurkar
    Anand Nerurkar
  • Feb 18
  • 2 min read

edit docker-compose.yml and add entry for zipkin and jaeger

version: '3'

services:

otel-collector:

image: otel/opentelemetry-collector-contrib:0.82.0

restart: always

command:

- --config=/etc/otelcol-contrib/otel-collector.yml

volumes:

- ./docker/collector/otel-collector.yml:/etc/otelcol-contrib/otel-collector.yml

ports:

- "1888:1888" # pprof extension

- "8888:8888" # Prometheus metrics exposed by the collector

- "8889:8889" # Prometheus exporter metrics

- "13133:13133" # health_check extension

- "4317:4317" # OTLP gRPC receiver

- "4318:4318" # OTLP http receiver

- "55679:55679" # zpages extension


depends_on:

- jaeger-all-in-one

- zipkin-all-in-one


prometheus:

container_name: prometheus

image: prom/prometheus

restart: always

command:

- --config.file=/etc/prometheus/prometheus.yml

volumes:

- ./docker/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml

ports:

- "9090:9090"


grafana:

container_name: grafana

image: grafana/grafana

ports:

- "3000:3000"

# Jaeger

jaeger-all-in-one:

image: jaegertracing/all-in-one:latest

restart: always

ports:

- "16686:16686"

- "14268"

- "14250"


# Zipkin

zipkin-all-in-one:

image: openzipkin/zipkin:latest

restart: always

ports:

- "9411:9411"


edit otel-collector.yml as below for adding entry for zipkin and jager as exporter


receivers:

otlp:

protocols:

http:


processors:

batch:


exporters:

prometheus:

endpoint: "0.0.0.0:8889"

const_labels:

label1: value1

zipkin:

endpoint: "http://zipkin-all-in-one:9411/api/v2/spans"

format: proto


jaeger:

endpoint: jaeger-all-in-one:14250

tls:

insecure: true


extensions:

health_check:

pprof:

zpages:


service:

extensions: [health_check, pprof, zpages]

pipelines:

metrics:

receivers: [otlp]

processors: [batch]

exporters: [prometheus]


traces:

receivers: [otlp]

processors: [batch]

exporters: [jaeger,zipkin,otlp]


add entry for trace as service section above


add maven dependency below


<!-- https://mvnrepository.com/artifact/io.opentelemetry/opentelemetry-exporter-otlp -->

<dependency>

<groupId>io.opentelemetry</groupId>

<artifactId>opentelemetry-exporter-otlp</artifactId>

<version>1.45.0</version>

</dependency>


add below wntry in application.yml


tracing:

sampling:

probability: 1.0



=====qpplicqtion.yml--------

spring:

application:

name: springappotdemo


management:

endpoints:

web:

exposure:

include: health,metrics,prometheus


otlp:

metrics:

export:

step: 10s

tracing:

tracing:

sampling:

probability: 1.0




add below entry in main class


@Bean

public RestTemplate restTemplate(RestTemplateBuilder builder) {

return builder.build();

}


@RestController

class HelloController {


private static final Logger LOGGER = LoggerFactory.getLogger(HelloController.class);

private final RestTemplate restTemplate;

private final SleepService sleepService;


HelloController(RestTemplate restTemplate, SleepService sleepService) {

this.restTemplate = restTemplate;

this.sleepService = sleepService;

}


@GetMapping("/hello")

public String hello() {

LOGGER.info("---------Hello method started---------");

LOGGER.error("---------Hello method started, id missing!---------");

ResponseEntity<String> responseEntity = this.restTemplate.postForEntity("https://httpbin.org/post", "Hello, Cloud!", String.class);

return responseEntity.getBody();

}



build application and run it ,check trace in jaeger





 
 
 

Recent Posts

See All
SOC2

SOC 2  (System and Organization Controls 2) is a widely recognized compliance framework  that evaluates how an organization manages...

 
 
 
RTO & RPO

✅ 1. What is RTO (Recovery Time Objective)? Definition: RTO is the maximum acceptable downtime  after a failure or disaster.It defines...

 
 
 

Comments

Rated 0 out of 5 stars.
No ratings yet

Add a rating
  • Facebook
  • Twitter
  • LinkedIn

©2024 by AeeroTech. Proudly created with Wix.com

bottom of page