Giter Site home page Giter Site logo

demo-observability-boot's Introduction

Spring Observability Support in Spring Boot 3.0.0

Code supporting the blog post related to Spring Observability support in Spring Boot 3.0.0

Building the docs

$ ./mvnw clean install -Pdocs -pl docs

Building the samples

Just run the Maven command to build the samples

$ ./mvnw clean install

Grafana dashboard sample

Resources used to build this demo

Building the image used in docker-compose

  1. app-server and app-boot-3 are compiled with native profile, installation of the necessary tools can be found in the file docker/ci/Dockerfile-nativeBuilder

app-client build using jib
$ mvn -pl app-client clean compile jib:dockerBuild -Djib.to.image=app-client:v1
app-boot-2 build build using jib
$ mvn -pl app-boot-2 clean compile jib:dockerBuild -Djib.to.image=app-boot-2:v1
app-boot-3 build native
$ mvn -Pnative -pl app-boot-3 native:compile
$ bash -c "cd app-boot-3 && docker build -t app-boot-3:v1 . "
app-server build native
$ mvn -Pnative -pl app-server native:compile
$ bash -c "cd app-server && docker build -t app-server:v1 . "

How to run

Run the obesrvability stack : grafana, loki, tempo, prometheus
$ docker compose up
Run the applications
$ docker compose --profile app up
  1. Go to Grafana, go to dashboards, and click on the Logs, Traces, Metrics dashboard. There you can pick a trace ID value (for example, bbe3aea006077640b66d40f3e62f04b9) to find all logs and traces from both applications that correspond to that trace ID.

Run IntelliJ IDE for developments
$ ./runIdea.sh

Notes

  1. no span created with contextualName using annotation but span are created using code @see FlightApplication.java

  2. this command should build image using local docker service but it fails

mvn -Pnative -pl app-server spring-boot:build-image

native stats

 PID %CPU  %MEM        VSZ       RSS TT          TIME   CMD
2982  1.2   1.2    12,76GB  393,91MB pts/5   00:00:12   .sdkman/candidates/java/22.3.r17-nik/bin/java -cp app-boot-2/target/classes:org/springframework/boot/spring-boot/2.7.7/spring-boot
2723  1.4   0.8    12,79GB  279,57MB pts/4   00:00:15   .sdkman/candidates/java/22.3.r17-nik/bin/java -cp app-boot-3/target/classes:org/springframework/boot/spring-boot/3.0.0/spring-boot
3824  0.6   0.4     1,96GB  142,65MB pts/3   00:00:05   ./app-server/target/app-server
4029  0.4   0.4     2,09GB  141,13MB pts/6   00:00:04   ./app-client/target/app-client

redhat openshift local

# download crc executable and put in /usr/local/bin
crc setup
crc start
# open web console, should be https://console-openshift-console.apps-crc.testing/
crc console
# show credential to login
crc console --credentials
#oc login -u developer https://api.crc.testing:6443
oc config use-context crc-admin
oc whoami

crc stop
crc delete # warning, this will delete all !
crc cleanup # The crc cleanup command removes an existing Red Hat OpenShift Local instance and reverts changes to DNS entries created by the crc setup command
docker pull registry
docker run -d -p 5000:5000 --restart=always --name registry registry:2
push image to openshift registry
oc config use-context crc-admin
oc registry login --insecure=true

export OC_PROJECT=demo-obs
oc delete project $OC_PROJECT
oc new-project $OC_PROJECT

export APP=app-client VERSION=v1 \
&& docker tag $APP:$VERSION localhost:5000/$APP:$VERSION \
&& docker push localhost:5000/$APP:$VERSION \
&& oc image mirror localhost:5000/$APP:$VERSION=default-route-openshift-image-registry.apps-crc.testing/$OC_PROJECT/$APP:$VERSION --insecure=true --filter-by-os=linux/amd64

export APP=app-server VERSION=v1 \
&& docker tag $APP:$VERSION localhost:5000/$APP:$VERSION \
&& docker push localhost:5000/$APP:$VERSION \
&& oc image mirror localhost:5000/$APP:$VERSION=default-route-openshift-image-registry.apps-crc.testing/$OC_PROJECT/$APP:$VERSION --insecure=true --filter-by-os=linux/amd64

export APP=app-boot-2 VERSION=v1 \
&& docker tag $APP:$VERSION localhost:5000/$APP:$VERSION \
&& docker push localhost:5000/$APP:$VERSION \
&& oc image mirror localhost:5000/$APP:$VERSION=default-route-openshift-image-registry.apps-crc.testing/$OC_PROJECT/$APP:$VERSION --insecure=true --filter-by-os=linux/amd64

export APP=app-boot-3 VERSION=v1 \
&& docker tag $APP:$VERSION localhost:5000/$APP:$VERSION \
&& docker push localhost:5000/$APP:$VERSION \
&& oc image mirror localhost:5000/$APP:$VERSION=default-route-openshift-image-registry.apps-crc.testing/$OC_PROJECT/$APP:$VERSION --insecure=true --filter-by-os=linux/amd64

oc get is
# with all parameters :
# oc process -f openshift/app-template.yml -p APP=app-boot-2 -p VERSION=v1 -p NAMESPACE=demo-obs -p GROUP=my-group | oc create -f -
oc process -f openshift/app-template.yml -p APP=app-boot-2 | oc apply -f -
oc process -f openshift/app-template.yml -p APP=app-boot-3 | oc apply -f -
oc process -f openshift/app-template.yml -p APP=app-server | oc apply -f -
oc process -f openshift/app-template.yml -p APP=app-client | oc apply -f -
  1. Go to web console, login as admin kubeadmin, select project demo-obs, go to Topology view, client on app-client deployment then show logs You should get output similar to this:

Client side logs
2023-01-16T08:50:01.786Z INFO [app-client,,] 1 --- [ main] com.example.client.ClientApplication : Started ClientApplication in 6.408 seconds (process running for 7.043)
2023-01-16T08:50:01.921Z INFO [app-client,377c7685b7ad7ab63b7ba9d5d823d82c,f0835ee782e5228f] 1 --- [ main] com.example.client.ClientApplication : Will send a request to the server
2023-01-16T08:50:02.120Z INFO [app-client,377c7685b7ad7ab63b7ba9d5d823d82c,f0835ee782e5228f] 1 --- [ main] com.example.client.ClientApplication : Got response [foo]
2023-01-16T08:50:02.122Z INFO [app-client,377c7685b7ad7ab63b7ba9d5d823d82c,f0835ee782e5228f] 1 --- [ main] com.example.client.ClientApplication : call boot-3 flight service
2023-01-16T08:50:02.204Z INFO [app-client,377c7685b7ad7ab63b7ba9d5d823d82c,f0835ee782e5228f] 1 --- [ main] com.example.client.ClientApplication : boot-3 flight service response: [{"id":1,"origin":"Paris","destination":"New-York"},{"id":2,"origin":"New-York","destination":"Paris"},{"id":3,"origin":"Londre","destination":"Bruxelles"},{"id":4,"origin":"Rome","destination":"Madrid"},{"id":5,"origin":"Porto","destination":"Seoul"}]
2023-01-16T08:50:02.205Z INFO [app-client,377c7685b7ad7ab63b7ba9d5d823d82c,f0835ee782e5228f] 1 --- [ main] com.example.client.ClientApplication : call boot-2 application
2023-01-16T08:50:02.530Z INFO [app-client,377c7685b7ad7ab63b7ba9d5d823d82c,f0835ee782e5228f] 1 --- [ main] com.example.client.ClientApplication : boot-2 response: ok !
oc get all --selector app=$APP -o name
oc delete all --selector app=$APP
oc delete project $OC_PROJECT

Openshift local divers

openshift registry how to
oc registry login --insecure=true
oc image mirror registry.access.redhat.com/ubi8/ubi:latest=default-route-openshift-image-registry.apps-crc.testing/demo/ubi8:latest --insecure=true --filter-by-os=linux/amd64
oc get is
oc set image-lookup ubi8
oc run demo --image=ubi8 --command -- sleep 600s
# after this an app can be added using
# image-registry.openshift-image-registry.svc:5000/demo/ubi8
# or
# default-route-openshift-image-registry.apps-crc.testing/demo/ubi8:latest
add container image using console
in web console add > container images
multirepo-oab.si.fr.intraorange:5002/nfpatrs/observability/app-server:v1
check Allow Images from insecure registries
create secret with <bvgg0760>:<secret> found in: cat /home/bvgg0760/.docker/config.json

helm

create new namespace for helm
export OC_PROJECT=demo-helm
oc new-project $OC_PROJECT
  1. upload images to new namespace registry

convert template to helm charts
# from https://github.com/redhat-cop/template2helm
template2helm convert --template ./openshift/app-template.yml --chart ./openshift/charts
#add "apiVersion: v2" on top of Chat.yaml file so helm lint will not complains
helm lint openshift/charts/app-template/
install with helm
helm install --set app=app-boot-2 --set namespace=demo-helm app-boot-2-chart openshift/charts/app-template
helm install --set app=app-boot-3 --set namespace=demo-helm app-boot-3-chart openshift/charts/app-template
helm install --set app=app-server --set namespace=demo-helm app-server-chart openshift/charts/app-template
helm install --set app=app-client --set namespace=demo-helm app-client-chart openshift/charts/app-template
clean helm
helm delete app-boot-2-chart
helm delete app-boot-3-chart
helm delete app-server-chart
helm delete app-client-chart

demo-observability-boot's People

Contributors

rudyremoissonnet avatar marcingrzejszczak avatar buzzardo avatar jonatan-ivanov 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.