Using OpenTelemetry and JaegerUI with SpringBoot 2.5 - spring-boot

I'm trying to build a monitoring system for a Springboot application. I need to send some metrics to an OpenTelemetry collector and then to Jaeger.
I'm setting up Jaeger and OpenTelemetry via docker compose, these are my docker-compose.yml and otel-collector-config.yml
version: "3.3"
services:
otel-collector:
image: otel/opentelemetry-collector:latest
command: [ "--config=/etc/otel-collector-config.yaml" ]
volumes:
- ./otel-collector-config.yaml:/etc/otel-collector-config.yaml:Z
ports:
- "13133:13133" # Health_check extension
- "4317:4317" # OTLP gRPC receiver
depends_on:
- jaeger-all-in-one
jaeger-all-in-one:
image: jaegertracing/all-in-one:latest
container_name: jaeger-all-in-one
ports:
- "16686:16686"
- "14268:14268"
- "14250:14250"
receivers:
otlp:
protocols:
grpc:
endpoint: otel-collector:4317
exporters:
jaeger:
endpoint: jaeger-all-in-one:14250
tls:
insecure: true
processors:
batch:
extensions:
health_check:
service:
extensions: [health_check]
pipelines:
traces:
receivers: [otlp]
processors: [batch]
exporters: [jaeger]
Also, these are my pom.xml dependecies:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-sleuth</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-sleuth-brave</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-sleuth-otel-autoconfigure</artifactId>
</dependency>
<dependency>
<groupId>io.opentelemetry</groupId>
<artifactId>opentelemetry-exporter-otlp-trace</artifactId>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-okhttp</artifactId>
<version>1.42.1</version>
</dependency>
And i put in application.properties:
spring.application.name = myName
sleuth.enabled= true
sleuth.otel.exporter.otlp.endpoint= http://localhost:4317
If I try to start the application I see that tracing is active and traceId and span are logged, but Jaeger does not receive anything, and the service is not even displayed.
I'm running out of ideas...

Related

SpringBoot JPA save in Impala

I develop a web service whit springboot and I need it save some info in my impala database.
I searching about save in impala and I only find how to use the JDBC.
Someone know if I can use spring boot and spring jpa to save data in impala?
My .yml
server:
port: 8080
spring:
config:
name: **
cloud:
loadbalancer:
ribbon:
enable: false
datasource:
url: jdbc:impala://...
username: ...
password: ...
driver-class-name: io.opentracing.contrib.jdbc.TracingDriver (I think this is not the correct but i find another)
My pom.xml
<dependencies>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.6</version>
</dependency>
<dependency>
<groupId>com.cloudera.impala.jdbc</groupId>
<artifactId>ImpalaJDBC41</artifactId>
<version>2.6.4.1005</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<dependency>
<groupId>es.caser.archit.spring</groupId>
<artifactId>db-caf-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>es.caser.archit.spring</groupId>
<artifactId>rest-caf-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>es.caser.archit.spring</groupId>
<artifactId>test-caf-boot-starter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>es.caser.archit.spring</groupId>
<artifactId>security-caf-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>com.github.ulisesbocchio</groupId>
<artifactId>jasypt-spring-boot-starter</artifactId>
<version>2.1.0</version>
</dependency>
</dependencies>
Thanks :D
The driver class name should be
driverClassName: org.apache.hive.jdbc.HiveDriver
And use this dependency
<dependency>
<groupId>org.apache.hive</groupId>
<artifactId>hive-jdbc</artifactId>
<version>3.1.2</version>
</dependency>

Spring boot gateway error - Unable to find RoutePredicateFactory with name path

I'm using Spring boot cloud gateway.
Spring version is 2.3.4.RELEASE
My eureka server is working well and other configurations are working well.
But when I gonna run the cloud gateway the Spring gives an error like bellow.
org.springframework.context.ApplicationContextException: Failed to start bean 'eurekaAutoServiceRegistration'; nested exception is reactor.core.Exceptions$ErrorCallbackNotImplemented: java.lang.IllegalArgumentException: Unable to find RoutePredicateFactory with name path
My cloud gateway configurations are like this.
spring:
cloud:
gateway:
routes:
- id: sripy-client
uri: localhost:8080
predicates:
- path=/client/
application:
name: API-GATEWAY
eureka:
client:
register-with-eureka: true
fetch-registry: true
service-url:
defaultZone: http://localhost:8761/eureka/
instance:
hostname: localhost
server:
port: 8989
and porm.xml like this.
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.4.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.example.gateway</groupId>
<artifactId>example.gateway</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>example.gateway</name>
<description>example gateway</description>
<properties>
<java.version>1.8</java.version>
<spring-cloud.version>Hoxton.SR8</spring-cloud.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-gateway</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
please help me to resolve this issue!
The problem is your predicates > path in yml file. the first letter must be a capital letter, in your case p of the path must be capital like this - Path=/client/
Entire yml file
spring:
cloud:
gateway:
routes:
- id: sripy-client
uri: localhost:8080
predicates:
- Path=/client/ #first letter must be a capital letter
application:
name: API-GATEWAY
eureka:
client:
register-with-eureka: true
fetch-registry: true
service-url:
defaultZone: http://localhost:8761/eureka/
instance:
hostname: localhost
server:
port: 8989

Zipkin data not able to persist in Elastic search

I am having problem persisting the zipkin data. I did not get any error message. So I am sharing configuration to get a help.
I can see my logs in zipkin UI, but not able to persist in elastic search.
My zipkin-service pom file shared below.
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-eureka</artifactId>
</dependency>
<dependency>
<groupId>io.zipkin.java</groupId>
<artifactId>zipkin-autoconfigure-ui</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-sleuth-zipkin-stream</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-stream-binder-rabbit</artifactId>
</dependency>
<dependency>
<groupId>io.zipkin.java</groupId>
<artifactId>zipkin-autoconfigure-storage-elasticsearch-http</artifactId>
<version>2.0.0</version>
</dependency>
<!-- add the dependency for elasticsearch via http -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
And my properties looks like this
spring:
profiles: local
rabbitmq:
host: ${RABBIT_HOST:localhost}
username: test
password: test
zipkin:
storage:
type: elasticsearch
elasticsearch:
jest:
uris: http://localhost:9200

Sleuth + Zipkins with Elasticsearch

Can anyone point me towards the required/working configuration to use Elasticsearch as a storage type with Zipkins with Sleuth?
pom.xml
'
<description>Spring Boot Zipkin Server</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.3.7.RELEASE</version>
</parent>
<properties>
<docker.image.prefix>springio</docker.image.prefix>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
<sonar.skip>true</sonar.skip>
<zipkin.version>1.6.0</zipkin.version>
<elasticsearch.version>2.3.4</elasticsearch.version>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Camden.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-sleuth-zipkin-stream</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-sleuth</artifactId>
</dependency>
<!-- EXAMPLE FOR RABBIT BINDING -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-stream-binder-rabbit</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.restdocs</groupId>
<artifactId>spring-restdocs-mockmvc</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<finalName>demo-zipkin-server</finalName>
</configuration>
</plugin>
</plugins>
</build>
`
application.yml
server:
port: 9411
spring:
rabbitmq:
host: ${RABBIT_HOST:localhost}
eureka:
client:
register-with-eureka: true
service-url:
defaultZone: http://localhost:8761/eureka/
zipkin:
self-tracing:
enabled: false
storage:
type: elasticsearch
elasticsearch:
cluster: ${ES_CLUSTER:elasticsearch}
hosts: ${ES_HOSTS:localhost:9300}
index: ${ES_INDEX:zipkin}
index-shards: ${ES_INDEX_SHARDS:5}
index-replicas: ${ES_INDEX_REPLICAS:1}
Application doesn't start up with these config. It throws
Caused by: java.lang.NoSuchMethodError: org.springframework.integration.amqp.support.DefaultAmqpHeaderMapper.inboundMappe
Classpath problems like you've posted are version-specific. Please update to most recent versions of dependencies.
For example, you can start with a base project using start.spring.io or otherwise to get something with recent deps. You could also copy a project like this:
https://github.com/openzipkin/sleuth-webmvc-example
Zipkin currently has native support for elasticsearch (meaning it does not use the Elasticsearch driver). So, the dependency to automatically configure this is:
<!-- override sleuth's zipkin version since we are using latest -->
<dependency>
<groupId>io.zipkin.java</groupId>
<artifactId>zipkin</artifactId>
<version>1.28.1</version>
</dependency>
<!-- add the dependency for elasticsearch via http -->
<dependency>
<groupId>io.zipkin.java</groupId>
<artifactId>zipkin-autoconfigure-storage-elasticsearch-http</artifactId>
<version>1.28.1</version>
</dependency>
Minimally set zipkin.storage.type=elasticsearch. Then, set you are overriding taking note that elasticsearch's http port is 9200 not 9300
Finally, please upvote native RabbitMQ support in zipkin so you don't need to do any of this! https://github.com/openzipkin/zipkin/issues/1614
Use spring cloud stream collector http://cloud.spring.io/spring-cloud-sleuth/spring-cloud-sleuth.html#_spring_cloud_sleuth_stream_zipkin_collector with an elasticsearch data store https://github.com/openzipkin/zipkin/blob/master/zipkin-server/README.md#elasticsearch-storage

Spring Cloud turbine - No data returned from /turbine.stream

My techstack comprises of the following
Eureka Discovery server
Zuul Gateway
Spring Config server
Hystrix Dashboard
My core services that has Hystrix stream enabled.
Hystrix dashboard is working fine as I am able to stream using the hystrics.stream exposed out of my services.
However, whenever I try to add turbine to this stack, the /turbine.stream only returns data: {"type":"Ping"} repeatedly on the browser and as a result Hystrix dashboard shows Unable to connect to Command Metric Stream
Can someone please assist me to find out where I am going wrong?
Here are my key configurations for turbine. The TurbineAppliation class is just a springboot app with #EnableTurbineStream so not listing it down below.
pom dependencies:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.1.RELEASE</version>
</parent>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Camden.SR5</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-config-client</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-turbine-stream</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-stream-rabbit</artifactId>
</dependency>
</dependencies>
bootstrap.yml: (Please ignore eureka specific config if it does not matter as I have not tuned them myself). The config server and eureka settings are same for all the other components which are working just fine.
spring:
application:
name: Turbine
cloud:
config:
enabled: true
discovery:
enabled: true
serviceId: ConfigServer
management:
security:
enabled: false
eureka:
instance:
leaseRenewalIntervalInSeconds: 10
# leaseExpirationDurationInSeconds: 2
preferIpAddress: true
ipAddress: 127.0.0.1
client:
serviceUrl:
defaultZone: http://localhost:8761/discovery/eureka/ ---discovery is my eureka context root required for my app
application.yml
server:
port: 7980
info:
component: Turbine App
turbine:
aggregator:
clusterConfig: MY-SERVICE
appConfig: MY-SERVICE
clusterNameExpression: new String('default')
InstanceMonitor:
eventStream:
skipLineLogic:
enabled: false
Hi I am dealing with the same problem using Camden.SR6.
After adding following in Turbine Service pom.xml, I was able to use turbine stream in hystrix dashboard:
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-netflix-hystrix-amqp</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-bus-amqp</artifactId>
</dependency>
Also I added : spring.rabbitmq.address=rabbit-mq-server:5672 to bootstrap.properties file.
With the new version of Spring Cloud Camden SR5 the rabbitMQ queue renamed from springCloudHystrixStream to turbineStreamInput.
As a workaround you can specify the previous version of spring-cloud-stream.
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-stream</artifactId>
<version>1.1.0.RELEASE</version>
</dependency>
Use for turbine app in your pom
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-netflix</artifactId>
<version>1.3.0.M1</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

Resources