Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Cloud-Native Observability with OpenTelemetry

You're reading from   Cloud-Native Observability with OpenTelemetry Learn to gain visibility into systems by combining tracing, metrics, and logging with OpenTelemetry

Arrow left icon
Product type Paperback
Published in May 2022
Publisher Packt
ISBN-13 9781801077705
Length 386 pages
Edition 1st Edition
Arrow right icon
Author (1):
Arrow left icon
Alex Boten Alex Boten
Author Profile Icon Alex Boten
Alex Boten
Arrow right icon
View More author details
Toc

Table of Contents (17) Chapters Close

Preface 1. Section 1: The Basics
2. Chapter 1: The History and Concepts of Observability FREE CHAPTER 3. Chapter 2: OpenTelemetry Signals – Traces, Metrics, and Logs 4. Chapter 3: Auto-Instrumentation 5. Section 2: Instrumenting an Application
6. Chapter 4: Distributed Tracing – Tracing Code Execution 7. Chapter 5: Metrics – Recording Measurements 8. Chapter 6: Logging – Capturing Events 9. Chapter 7: Instrumentation Libraries 10. Section 3: Using Telemetry Data
11. Chapter 8: OpenTelemetry Collector 12. Chapter 9: Deploying the Collector 13. Chapter 10: Configuring Backends 14. Chapter 11: Diagnosing Problems 15. Chapter 12: Sampling 16. Other Books You May Enjoy

Generating tracing data

It's finally time to start generating telemetry from the application! There are several ways to create a span in OpenTelemetry; the first one we'll use is to call start_span on the tracer instance we obtained previously. This will create a span object, using the only required string argument as the name of the span. The span object is the building block of distributed tracing and is intended to represent a unique unit of work in our application. In the following example, we will create a new Span object before calling a method that will do some work. Since our application is a shopper, the first thing the shopper will do is browse the store. In order for the tracing data to be useful, it's important to use a meaningful name in the creation of the span. Once browse has returned, we will call end on the span object to signal that the work is complete:

shopper.py

def browse():
    print("visiting the grocery store&quot...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €18.99/month. Cancel anytime