Skip to content

Latest commit

 

History

History
71 lines (57 loc) · 2.15 KB

README.md

File metadata and controls

71 lines (57 loc) · 2.15 KB

Front Service

simulating back-to-front service

Microservice Architecture

 --------------------             ------------------            ------------------      
| Client(UI/Browser) | =======> | Front api service | =======> | Customer service |   
 --------------------             ------------------            ------------------

Execute using IDE/command line

1. Start the customer service first (reference link given below)
2. Then Start the front api service using command: mvn spring-boot:run
3. Open browser: http://localhost:8080/customerDetails/1
Reference: customer service

Execute using Docker

1. Start the customer service. . Reference link is mentioned above.
2. Start the front-api-service using Docker.
    docker network create tracing(ignore this step if already done)
    docker pull rduttaxebia/otel-demo-api-service:latest
    docker run --name front-service --network tracing -p 8080:8080 rduttaxebia/otel-demo-api-service:latest

Enable OpenTelemetry

  1. Add the following dependencies in pom.xml
		<dependency>
			<groupId>org.springframework.cloud</groupId>
			<artifactId>spring-cloud-sleuth-zipkin</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework.cloud</groupId>
			<artifactId>spring-cloud-starter-sleuth</artifactId>
		</dependency>
  1. Add/append the following in application.yml
spring:
    zipkin:
        baseUrl: http://localhost:9411
    sleuth:
        sampler:
            probability: 1.0 # allowed values between 0.0 - 0.1
  1. Start a zipkin server using Docker (ignore if already started)
docker network create tracing
docker run -d --rm -it --name zipkin --network tracing -p 9411:9411 openzipkin/zipkin:latest
  1. Restart the service (check the Execute section above)

Instrumenting by injecting agent during startup

export OTEL_EXPORTER_ZIPKIN_ENDPOINT=http://localhost:9411/api/v2/spans
export OTEL_TRACES_EXPORTER=zipkin
export OTEL_SERVICE_NAME=front-service
java -javaagent:opentelemetry-javaagent.jar  -jar target/*.jar