SlideShare a Scribd company logo
Distributed tracing
Unified microservices:
The service mesh story
—
Denilson Nastacio
Senior Software Eng.
@dnastacio
sourcepatch.blogspot.com
github.com/nastacio/
About me
husband
father of 3 (boys)
educator
(little league) soccer coach
backyard farmer
master inventor
cancer fighter (former)
anime and sci-fi fan
avid reader
aspiring writer
IBM Cloud / March 12, 2020 / © 2020 IBM Corporation 2
http://sourcepatch.blogspot.com/search/label/clinical_trials
http://www.rtpscrolls.com/
Contents
IBM Cloud / March 12, 2020 / © 2020 IBM Corporation 3
Introduction
Why microservices? 04
Landscape 06
Observability 07
Instrumentation
Example microservices architecture 12
Istio injection 11
Distributed Tracing Model 12
Code modifications 13
Visualization
Grafana (monitoring externals) 19
Kiali (monitoring internals) 20
Jaeger (tracing) 21
Introduction
Microservices
Cloud Native Landscape
Service mesh
Distributed Tracing Data Model
IBM Cloud / March 12, 2020 / © 2020 IBM Corporation 4
Time
Why microservices?
IBM Cloud / March 12, 2020 / © 2020 IBM Corporation
5
“Fridayafternoon”
Time
Why microservices?
IBM Cloud / March 12, 2020 / © 2020 IBM Corporation 6
“When you hit a wall,
focus on one brick.”
Tyler May
“Fridayafternoon”
“And don’t forget the
manuals and brick
adapters.”
Me
The landscape
Observability and
Analysis
IBM Cloud / March 12, 2020 / © 2020 IBM Corporation 8
Monitoring
Tracing
Logging
What…
• …is working?
• …is not working
When…
• …did it start?
• …does it happen? Fixed, cyclic,
random?
• …does it happen? Deploy, start,
runtime?
• …worsening or stable?
Where…
• …which instances?
• …which functions?
• …which regions?
• …in combination with others?
Why…
• What is connected to what?
• What is not connected to what?
• What is taking too long?
• Why is taking too long?
• How different are those two
transactions?
• Where is this request going
through?
• “Unable to connect to SSL services due to ‘PKIX Path
Building Failed’
• “Printing is not supported on this printer”
• “Initiating shutdown of Southeast region”
• “Installation succeeded but failed with errors.”
• “Failed to startup SSH session: Socket error: success
Distributed Tracing
Data Model
IBM Cloud / March 12, 2020 / © 2020 IBM Corporation 9
https://github.com/opentracing/specification/blob/master/specification.md
• Traces
• Spans
• References
Collection of spans (directed acyclic graph)
Typically associated with a business transaction
Microservice “C”
Microservice “A”
Microservice “B”
• Operation name
• Start and finish timestamp
• Tags
• Logs
• Baggage Items
• References to causally-related spans
Trace id: 124861aedfa quoteItem
Span “quoteItem”
Span “B-phase 1” Span “B-phase 2”
ChildOfChildOf
Span “quoteItem”
“B-phase 1” “B-phase 2”
Time
Istio Injection
IBM Cloud / March 12, 2020 / © 2020 IBM Corporation 10
Istio.io
• Connect
• Secure
• Control
• Observe
Microservice A
Microservice C
Microservice B
3rd party service
Observe
Instrumentation with
Node.js, Java Spring
Boot, JEE (Open Liberty)
IBM Cloud / March 12, 2020 / © 2020 IBM Corporation 11
Microservice “C”
Microservice “A”
Microservice “B”
Business transaction
OpenTracing traffic
Jaeger Backend Jaeger UI
Kiali UI
Prometheus
Istio injection traffic
Our program(s) for
today Grafana
Istio injection
IBM Cloud / March 12, 2020 / © 2020 IBM Corporation 13
$ kubectl label namespace tracing istio-injection=enabled
$ kubectl get deployment nodejs-tracing -o yaml | 
istioctl kube-inject -f - | 
kubectl apply -f -
or
+
metadata:
annotations:
...
sidecar.istio.io/inject: "true"
...
labels:
app: nodejs-tracing
version: v1
...
deployment.yaml
Automatic injection on
all deployments
across entire
namespace
Injection to specific
deployment
nodejs-tracing
├ app.js
└ package.json
Distributed Tracing
Microservice “A” (Node.js)
IBM Cloud / March 12, 2020 / © 2020 IBM Corporation 14
const opentracing = require('opentracing')
var initTracerFromEnv = require('jaeger-client').initTracerFromEnv
var config = { serviceName: 'app-a-nodejs' }
var options = {}
var tracer = initTracerFromEnv(config, options)
...
app.get('/node-springboot', (req, res) => {
const wireCtx = tracer.extract(opentracing.FORMAT_HTTP_HEADERS, req.headers)
const span = tracer.startSpan(spanName, { childOf: wireCtx })
span.log({ event: 'request_received' })
...
span.finish()
}
app.js
{
"name": "app-a-nodejs",
...,
"dependencies": {
"jaeger-client": ...,
"opentracing": ...,
...
},
}
package.json
springboot-tracing
├ pom.xml
└ src/main/java/application
├ Main.java
└ ServiceResource.java
Distributed Tracing
Microservice “B” (Spring Boot)
IBM Cloud / March 12, 2020 / © 2020 IBM Corporation 15
import io.jaegertracing.Configuration;
import io.opentracing.Tracer;
@SpringBootApplication
public class Main {
@Bean
public Tracer initTracer() {
return Configuration.fromEnv("app-b-springboot").getTracer();
}
Main.java
<dependencies>
...
<groupId>io.opentracing.contrib</groupId>
<artifactId>opentracing-spring-cloud-starter</artifactId>
...
<groupId>io.opentracing</groupId>
<artifactId>opentracing-api</artifactId>
...
<groupId>io.jaegertracing</groupId>
<artifactId>jaeger-client</artifactId>
...
</dependencies>
pom.xml
import io.opentracing.Span;
import io.opentracing.Tracer;
import io.opentracing.tag.Tags;
@RestController
public class ServiceResource {
@Autowired
private Tracer tracer;
@GetMapping(value = "/resource", produces = "application/json")
public ResponseEntity<Object> quoteItem(...) {
...
Span parentSpan = tracer.scopeManager().activeSpan();
Span spanPhase1 = tracer.buildSpan("phase_1")
.asChildOf(parentSpan).start();
...
spanPhase1.setTag(Tags.ERROR.getKey(), true);
...
spanPhase1.finish();
}
ServiceResource.java
jee-tracing
├ pom.xml
├ src/main
├ java/application
│ └ ServiceResource.java
└ main/liberty
└ server.xml
Distributed Tracing
Microservice “C” (Open Liberty)
IBM Cloud / March 12, 2020 / © 2020 IBM Corporation 16
<server description="Liberty server">
<featureManager>
<feature>microProfile-3.2</feature>
<feature>mpOpenTracing-1.3</feature>
...
<webApplication location="app-c-jee.war" contextRoot="/" >
<classloader apiTypeVisibility="+third-party" />
</webApplication>
</server>
server.xml
<dependencies>
...
<groupId>io.jaegertracing</groupId>
<artifactId>jaeger-client</artifactId>
pom.xml
import io.opentracing.Scope;
import io.opentracing.Tracer;
import io.opentracing.tag.Tags;
@Path("/resource”)
public class ServiceResource {
@Inject
private Tracer tracer;
@GET
public ResponseEntity<Object> completeOrder(...) {
...
try (Scope childScope = tracer.buildSpan("phase_1")
.startActive(true)) {
...
childScope.span().setTag(Tags.ERROR.getKey(), true);
...
}
...
}
ServiceResource.
java
https://openliberty.io/blog/2019/12/06/microprofile-32-health-metrics-190012.html#jmo
Visualizations with
Grafana (monitoring)
Kiali (deeper monitoring)
Jaeger (tracing)
IBM Cloud / March 12, 2020 / © 2020 IBM Corporation 17
Grafana
IBM Cloud / March 12, 2020 / © 2020 IBM Corporation 18
• Charts and dashboards shareable
and composable through JSON
files
• Explore Data with PromQL, the
Prometheus Query Language
• PromQL = Prometheus Query
Language
• Dashboards contain multiple
charts
count by (destination_service_name,response_code)
(istio_requests_total{destination_service_namespace="tracing",response_code
!="200"})
Kiali
IBM Cloud / March 12, 2020 / © 2020 IBM Corporation 19
metadata:
...
labels:
app: nodejs-tracing
version: v1
...
deployment.yaml
Kiali
IBM Cloud / March 12, 2020 / © 2020 IBM Corporation 20
virtualservice.yaml
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: jee-tracing
spec:
hosts:
- jee-tracing
http:
- fault:
abort:
httpStatus: 502
percentage:
value: 30
route:
- destination:
host: jee-tracing
- route:
- destination:
host: jee-tracing
Kiali (workloads)
IBM Cloud / March 12, 2020 / © 2020 IBM Corporation 21
Jaeger
IBM Cloud / March 12, 2020 / © 2020 IBM Corporation 22
C
A
B
Jaeger – Troubleshooting
IBM Cloud / March 12, 2020 / © 2020 IBM Corporation 23
virtualservice.yaml
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: spring-tracing
spec:
hosts:
- spring-tracing
http:
- fault:
delay:
fixedDelay: 1s
percentage:
value: 90
route:
- destination:
host: spring-tracing
- route:
- destination:
host: spring-tracing
Closing thoughts
IBM Cloud / March 12, 2020 / © 2020 IBM Corporation 24
Best Practices for
Distributed Tracing
IBM Cloud / March 12, 2020 / © 2020 IBM Corporation 25
• Service Names
• Span names
• Tags
• Baggage
• Timestamps
• Extract span context when receiving a call
• Inject span context before making a call
https://opentracing.io/docs/best-practices/instrumenting-frameworks/
If no timestamp provided, “wall time” is used. How much precision do you need?
Service meshes like Istio will inject spans if none is found, but often you want to
propagate the context across many of the nodes servicing a higher-level transaction
There are some standard tags, such as “error”, “log”, HTTP request information, remote
peer information.
Baggage text
Takeaways
IBM Cloud / March 12, 2020 / © 2020 IBM Corporation 26
1. A basic understanding of how distributed tracing
relates to a product architecture
2. Concrete examples of how to instrument
microservices in a Kubernetes environment
3. Concrete examples of how to visualize and act upon
distribute tracing information
Next steps
IBM Cloud / March 12, 2020 / © 2020 IBM Corporation 27
Dive deeper into OpenTracing
https://opentracing.io/docs/overview
Complete source code and instructions for the technical bits
https://github.com/IBM/icpa-opentracing
(Yet another) great “101” guide from my colleague Carlos Santana:
https://ibm-cloud-architecture.github.io/learning-distributed-tracing-
101/docs/index.html
Try Istio locally
https://istio.io
Guided Istio workshop
https://learn.openshift.com/servicemesh/
Q & A

More Related Content

PDF
O Outro Lado BSidesSP Ed. 5 - As Nove Principais Ameaças na Computação em Nuvem
PDF
20101109 (tech ed) how frameworks kill projects
PDF
[Call for code] IBM 블록체인을 활용하여 투명하게 구호기금 관리하기 - Hyperledger Fabric v1.1 by 맹개발
PDF
Call For Code: 시각인식을 활용한 피해상황 파악하기 by 맹개발
PPTX
A Pulsar Use Case In Federated Learning - Pulsar Summit NA 2021
PPTX
Microsoft, java and you!
PPTX
Cloud native java workshop
PPTX
How to deploy machine learning models into production
O Outro Lado BSidesSP Ed. 5 - As Nove Principais Ameaças na Computação em Nuvem
20101109 (tech ed) how frameworks kill projects
[Call for code] IBM 블록체인을 활용하여 투명하게 구호기금 관리하기 - Hyperledger Fabric v1.1 by 맹개발
Call For Code: 시각인식을 활용한 피해상황 파악하기 by 맹개발
A Pulsar Use Case In Federated Learning - Pulsar Summit NA 2021
Microsoft, java and you!
Cloud native java workshop
How to deploy machine learning models into production

Similar to Distributed tracing with service meshes and tracing spans across polyglot Microservices (20)

PDF
Cloud-native Java EE-volution
KEY
Spring in the Cloud - using Spring with Cloud Foundry
PDF
Weave Your Microservices with Istio
PDF
All Things Open 2019 weave-services-istio
PDF
Ato2019 weave-services-istio
ODP
Open stack bigdata NY cloudcamp
PDF
Analyzing the Performance of Mobile Web
PPTX
From Zero to still Zero: The most beautiful mistakes going into the cloud.
PPT
Fowa Miami 09 Cloud Computing Workshop
PPTX
Seriously Open Cloud Native Java Microservices
PDF
SpringOne Tour: Deliver 15-Factor Applications on Kubernetes with Spring Boot
PPTX
New Design Patterns in Microservice Solutions
PDF
Weather data meets ibm cloud. part 4 analysis and visualization of weather ...
PPTX
Glue con2011 future_of_net_systems
PDF
Cloudy Ajax 08 10
PDF
Introduction to mago3D, an Open Source Based Digital Twin Platform
PDF
Logstash and Maxmind: not just for GEOIP anymore
PDF
Introduction to Apache NiFi 1.11.4
PDF
Using Data Science & Serverless Python to find apartment in Toronto
PDF
The Future of Cloud Innovation, featuring Adrian Cockcroft
Cloud-native Java EE-volution
Spring in the Cloud - using Spring with Cloud Foundry
Weave Your Microservices with Istio
All Things Open 2019 weave-services-istio
Ato2019 weave-services-istio
Open stack bigdata NY cloudcamp
Analyzing the Performance of Mobile Web
From Zero to still Zero: The most beautiful mistakes going into the cloud.
Fowa Miami 09 Cloud Computing Workshop
Seriously Open Cloud Native Java Microservices
SpringOne Tour: Deliver 15-Factor Applications on Kubernetes with Spring Boot
New Design Patterns in Microservice Solutions
Weather data meets ibm cloud. part 4 analysis and visualization of weather ...
Glue con2011 future_of_net_systems
Cloudy Ajax 08 10
Introduction to mago3D, an Open Source Based Digital Twin Platform
Logstash and Maxmind: not just for GEOIP anymore
Introduction to Apache NiFi 1.11.4
Using Data Science & Serverless Python to find apartment in Toronto
The Future of Cloud Innovation, featuring Adrian Cockcroft
Ad

More from Nebulaworks (19)

PDF
Dynamic Policy Enforcement for Microservice Environments
PDF
Overcoming scalability issues in your prometheus ecosystem
PDF
Why we chose Argo Workflow to scale DevOps at InVision
PDF
Methods to stay focused & productive amidst COVID-19!
PDF
Embracing service-level-objectives of your microservices in your Cl/CD
PDF
Embacing service-level-objectives of your microservices in your Cl/CD
PDF
Deploying to Day N Operations of Kubernetes and Containerized Apps
PDF
Trunk based development for Beginners
PDF
Managing Terraform Module Versioning and Dependencies
PDF
Kubernetes for Beginners
PDF
End to End immutable infrastructure testing
PDF
Building Modern Teams and Software
PDF
Kuberntes Ingress with Kong
PDF
A Hands-on Introduction on Terraform Best Concepts and Best Practices
PDF
The App Developer's Kubernetes Toolbox
PDF
Building a Container Platform with docker swarm
PDF
Effective Micoservice Design & Containers
PDF
Fast Tracking Dev Teams to Container Adoption
PDF
Nebulaworks | Optimize Your DevOps Game
Dynamic Policy Enforcement for Microservice Environments
Overcoming scalability issues in your prometheus ecosystem
Why we chose Argo Workflow to scale DevOps at InVision
Methods to stay focused & productive amidst COVID-19!
Embracing service-level-objectives of your microservices in your Cl/CD
Embacing service-level-objectives of your microservices in your Cl/CD
Deploying to Day N Operations of Kubernetes and Containerized Apps
Trunk based development for Beginners
Managing Terraform Module Versioning and Dependencies
Kubernetes for Beginners
End to End immutable infrastructure testing
Building Modern Teams and Software
Kuberntes Ingress with Kong
A Hands-on Introduction on Terraform Best Concepts and Best Practices
The App Developer's Kubernetes Toolbox
Building a Container Platform with docker swarm
Effective Micoservice Design & Containers
Fast Tracking Dev Teams to Container Adoption
Nebulaworks | Optimize Your DevOps Game
Ad

Recently uploaded (20)

PPT
Introduction Database Management System for Course Database
PDF
Nekopoi APK 2025 free lastest update
PPTX
history of c programming in notes for students .pptx
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PDF
Upgrade and Innovation Strategies for SAP ERP Customers
PPTX
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
PDF
System and Network Administraation Chapter 3
PPTX
CHAPTER 2 - PM Management and IT Context
PDF
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PDF
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
PDF
Which alternative to Crystal Reports is best for small or large businesses.pdf
PDF
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
PDF
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
PDF
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
PPTX
Transform Your Business with a Software ERP System
PPTX
VVF-Customer-Presentation2025-Ver1.9.pptx
PDF
How to Migrate SBCGlobal Email to Yahoo Easily
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
Introduction Database Management System for Course Database
Nekopoi APK 2025 free lastest update
history of c programming in notes for students .pptx
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
Upgrade and Innovation Strategies for SAP ERP Customers
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
System and Network Administraation Chapter 3
CHAPTER 2 - PM Management and IT Context
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
Adobe Illustrator 28.6 Crack My Vision of Vector Design
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
Which alternative to Crystal Reports is best for small or large businesses.pdf
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
Transform Your Business with a Software ERP System
VVF-Customer-Presentation2025-Ver1.9.pptx
How to Migrate SBCGlobal Email to Yahoo Easily
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025

Distributed tracing with service meshes and tracing spans across polyglot Microservices

  • 1. Distributed tracing Unified microservices: The service mesh story — Denilson Nastacio Senior Software Eng.
  • 2. @dnastacio sourcepatch.blogspot.com github.com/nastacio/ About me husband father of 3 (boys) educator (little league) soccer coach backyard farmer master inventor cancer fighter (former) anime and sci-fi fan avid reader aspiring writer IBM Cloud / March 12, 2020 / © 2020 IBM Corporation 2 http://sourcepatch.blogspot.com/search/label/clinical_trials http://www.rtpscrolls.com/
  • 3. Contents IBM Cloud / March 12, 2020 / © 2020 IBM Corporation 3 Introduction Why microservices? 04 Landscape 06 Observability 07 Instrumentation Example microservices architecture 12 Istio injection 11 Distributed Tracing Model 12 Code modifications 13 Visualization Grafana (monitoring externals) 19 Kiali (monitoring internals) 20 Jaeger (tracing) 21
  • 4. Introduction Microservices Cloud Native Landscape Service mesh Distributed Tracing Data Model IBM Cloud / March 12, 2020 / © 2020 IBM Corporation 4
  • 5. Time Why microservices? IBM Cloud / March 12, 2020 / © 2020 IBM Corporation 5 “Fridayafternoon”
  • 6. Time Why microservices? IBM Cloud / March 12, 2020 / © 2020 IBM Corporation 6 “When you hit a wall, focus on one brick.” Tyler May “Fridayafternoon” “And don’t forget the manuals and brick adapters.” Me
  • 8. Observability and Analysis IBM Cloud / March 12, 2020 / © 2020 IBM Corporation 8 Monitoring Tracing Logging What… • …is working? • …is not working When… • …did it start? • …does it happen? Fixed, cyclic, random? • …does it happen? Deploy, start, runtime? • …worsening or stable? Where… • …which instances? • …which functions? • …which regions? • …in combination with others? Why… • What is connected to what? • What is not connected to what? • What is taking too long? • Why is taking too long? • How different are those two transactions? • Where is this request going through? • “Unable to connect to SSL services due to ‘PKIX Path Building Failed’ • “Printing is not supported on this printer” • “Initiating shutdown of Southeast region” • “Installation succeeded but failed with errors.” • “Failed to startup SSH session: Socket error: success
  • 9. Distributed Tracing Data Model IBM Cloud / March 12, 2020 / © 2020 IBM Corporation 9 https://github.com/opentracing/specification/blob/master/specification.md • Traces • Spans • References Collection of spans (directed acyclic graph) Typically associated with a business transaction Microservice “C” Microservice “A” Microservice “B” • Operation name • Start and finish timestamp • Tags • Logs • Baggage Items • References to causally-related spans Trace id: 124861aedfa quoteItem Span “quoteItem” Span “B-phase 1” Span “B-phase 2” ChildOfChildOf Span “quoteItem” “B-phase 1” “B-phase 2” Time
  • 10. Istio Injection IBM Cloud / March 12, 2020 / © 2020 IBM Corporation 10 Istio.io • Connect • Secure • Control • Observe Microservice A Microservice C Microservice B 3rd party service Observe
  • 11. Instrumentation with Node.js, Java Spring Boot, JEE (Open Liberty) IBM Cloud / March 12, 2020 / © 2020 IBM Corporation 11
  • 12. Microservice “C” Microservice “A” Microservice “B” Business transaction OpenTracing traffic Jaeger Backend Jaeger UI Kiali UI Prometheus Istio injection traffic Our program(s) for today Grafana
  • 13. Istio injection IBM Cloud / March 12, 2020 / © 2020 IBM Corporation 13 $ kubectl label namespace tracing istio-injection=enabled $ kubectl get deployment nodejs-tracing -o yaml | istioctl kube-inject -f - | kubectl apply -f - or + metadata: annotations: ... sidecar.istio.io/inject: "true" ... labels: app: nodejs-tracing version: v1 ... deployment.yaml Automatic injection on all deployments across entire namespace Injection to specific deployment
  • 14. nodejs-tracing ├ app.js └ package.json Distributed Tracing Microservice “A” (Node.js) IBM Cloud / March 12, 2020 / © 2020 IBM Corporation 14 const opentracing = require('opentracing') var initTracerFromEnv = require('jaeger-client').initTracerFromEnv var config = { serviceName: 'app-a-nodejs' } var options = {} var tracer = initTracerFromEnv(config, options) ... app.get('/node-springboot', (req, res) => { const wireCtx = tracer.extract(opentracing.FORMAT_HTTP_HEADERS, req.headers) const span = tracer.startSpan(spanName, { childOf: wireCtx }) span.log({ event: 'request_received' }) ... span.finish() } app.js { "name": "app-a-nodejs", ..., "dependencies": { "jaeger-client": ..., "opentracing": ..., ... }, } package.json
  • 15. springboot-tracing ├ pom.xml └ src/main/java/application ├ Main.java └ ServiceResource.java Distributed Tracing Microservice “B” (Spring Boot) IBM Cloud / March 12, 2020 / © 2020 IBM Corporation 15 import io.jaegertracing.Configuration; import io.opentracing.Tracer; @SpringBootApplication public class Main { @Bean public Tracer initTracer() { return Configuration.fromEnv("app-b-springboot").getTracer(); } Main.java <dependencies> ... <groupId>io.opentracing.contrib</groupId> <artifactId>opentracing-spring-cloud-starter</artifactId> ... <groupId>io.opentracing</groupId> <artifactId>opentracing-api</artifactId> ... <groupId>io.jaegertracing</groupId> <artifactId>jaeger-client</artifactId> ... </dependencies> pom.xml import io.opentracing.Span; import io.opentracing.Tracer; import io.opentracing.tag.Tags; @RestController public class ServiceResource { @Autowired private Tracer tracer; @GetMapping(value = "/resource", produces = "application/json") public ResponseEntity<Object> quoteItem(...) { ... Span parentSpan = tracer.scopeManager().activeSpan(); Span spanPhase1 = tracer.buildSpan("phase_1") .asChildOf(parentSpan).start(); ... spanPhase1.setTag(Tags.ERROR.getKey(), true); ... spanPhase1.finish(); } ServiceResource.java
  • 16. jee-tracing ├ pom.xml ├ src/main ├ java/application │ └ ServiceResource.java └ main/liberty └ server.xml Distributed Tracing Microservice “C” (Open Liberty) IBM Cloud / March 12, 2020 / © 2020 IBM Corporation 16 <server description="Liberty server"> <featureManager> <feature>microProfile-3.2</feature> <feature>mpOpenTracing-1.3</feature> ... <webApplication location="app-c-jee.war" contextRoot="/" > <classloader apiTypeVisibility="+third-party" /> </webApplication> </server> server.xml <dependencies> ... <groupId>io.jaegertracing</groupId> <artifactId>jaeger-client</artifactId> pom.xml import io.opentracing.Scope; import io.opentracing.Tracer; import io.opentracing.tag.Tags; @Path("/resource”) public class ServiceResource { @Inject private Tracer tracer; @GET public ResponseEntity<Object> completeOrder(...) { ... try (Scope childScope = tracer.buildSpan("phase_1") .startActive(true)) { ... childScope.span().setTag(Tags.ERROR.getKey(), true); ... } ... } ServiceResource. java https://openliberty.io/blog/2019/12/06/microprofile-32-health-metrics-190012.html#jmo
  • 17. Visualizations with Grafana (monitoring) Kiali (deeper monitoring) Jaeger (tracing) IBM Cloud / March 12, 2020 / © 2020 IBM Corporation 17
  • 18. Grafana IBM Cloud / March 12, 2020 / © 2020 IBM Corporation 18 • Charts and dashboards shareable and composable through JSON files • Explore Data with PromQL, the Prometheus Query Language • PromQL = Prometheus Query Language • Dashboards contain multiple charts count by (destination_service_name,response_code) (istio_requests_total{destination_service_namespace="tracing",response_code !="200"})
  • 19. Kiali IBM Cloud / March 12, 2020 / © 2020 IBM Corporation 19 metadata: ... labels: app: nodejs-tracing version: v1 ... deployment.yaml
  • 20. Kiali IBM Cloud / March 12, 2020 / © 2020 IBM Corporation 20 virtualservice.yaml apiVersion: networking.istio.io/v1alpha3 kind: VirtualService metadata: name: jee-tracing spec: hosts: - jee-tracing http: - fault: abort: httpStatus: 502 percentage: value: 30 route: - destination: host: jee-tracing - route: - destination: host: jee-tracing
  • 21. Kiali (workloads) IBM Cloud / March 12, 2020 / © 2020 IBM Corporation 21
  • 22. Jaeger IBM Cloud / March 12, 2020 / © 2020 IBM Corporation 22 C A B
  • 23. Jaeger – Troubleshooting IBM Cloud / March 12, 2020 / © 2020 IBM Corporation 23 virtualservice.yaml apiVersion: networking.istio.io/v1alpha3 kind: VirtualService metadata: name: spring-tracing spec: hosts: - spring-tracing http: - fault: delay: fixedDelay: 1s percentage: value: 90 route: - destination: host: spring-tracing - route: - destination: host: spring-tracing
  • 24. Closing thoughts IBM Cloud / March 12, 2020 / © 2020 IBM Corporation 24
  • 25. Best Practices for Distributed Tracing IBM Cloud / March 12, 2020 / © 2020 IBM Corporation 25 • Service Names • Span names • Tags • Baggage • Timestamps • Extract span context when receiving a call • Inject span context before making a call https://opentracing.io/docs/best-practices/instrumenting-frameworks/ If no timestamp provided, “wall time” is used. How much precision do you need? Service meshes like Istio will inject spans if none is found, but often you want to propagate the context across many of the nodes servicing a higher-level transaction There are some standard tags, such as “error”, “log”, HTTP request information, remote peer information. Baggage text
  • 26. Takeaways IBM Cloud / March 12, 2020 / © 2020 IBM Corporation 26 1. A basic understanding of how distributed tracing relates to a product architecture 2. Concrete examples of how to instrument microservices in a Kubernetes environment 3. Concrete examples of how to visualize and act upon distribute tracing information
  • 27. Next steps IBM Cloud / March 12, 2020 / © 2020 IBM Corporation 27 Dive deeper into OpenTracing https://opentracing.io/docs/overview Complete source code and instructions for the technical bits https://github.com/IBM/icpa-opentracing (Yet another) great “101” guide from my colleague Carlos Santana: https://ibm-cloud-architecture.github.io/learning-distributed-tracing- 101/docs/index.html Try Istio locally https://istio.io Guided Istio workshop https://learn.openshift.com/servicemesh/
  • 28. Q & A