Cloud-Native Observability with OpenTelemetry

Book description

Leverage OpenTelemetry's API, libraries, tools and the collector to produce and collect telemetry along with using open-source tools to analyze distributed traces, check metrics and logs, and gain insights into application health

Key Features

  • Get to grips with OpenTelemetry, an open-source cloud-native software observability standard
  • Use vendor-neutral tools to instrument applications to produce better telemetry and improve observability
  • Understand how telemetry data can be correlated and interpreted to understand distributed systems

Book Description

Cloud-Native Observability with OpenTelemetry is a guide to helping you look for answers to questions about your applications. This book teaches you how to produce telemetry from your applications using an open standard to retain control of data. OpenTelemetry provides the tools necessary for you to gain visibility into the performance of your services. It allows you to instrument your application code through vendor-neutral APIs, libraries and tools.

By reading Cloud-Native Observability with OpenTelemetry, you’ll learn about the concepts and signals of OpenTelemetry - traces, metrics, and logs. You’ll practice producing telemetry for these signals by configuring and instrumenting a distributed cloud-native application using the OpenTelemetry API. The book also guides you through deploying the collector, as well as telemetry backends necessary to help you understand what to do with the data once it's emitted. You’ll look at various examples of how to identify application performance issues through telemetry. By analyzing telemetry, you’ll also be able to better understand how an observable application can improve the software development life cycle.

By the end of this book, you’ll be well-versed with OpenTelemetry, be able to instrument services using the OpenTelemetry API to produce distributed traces, metrics and logs, and more.

What you will learn

  • Understand the core concepts of OpenTelemetry
  • Explore concepts in distributed tracing, metrics, and logging
  • Discover the APIs and SDKs necessary to instrument an application using OpenTelemetry
  • Explore what auto-instrumentation is and how it can help accelerate application instrumentation
  • Configure and deploy the OpenTelemetry Collector
  • Get to grips with how different open-source backends can be used to analyze telemetry data
  • Understand how to correlate telemetry in common scenarios to get to the root cause of a problem

Who this book is for

This book is for software engineers, library authors, and systems operators looking to better understand their infrastructure, services and applications by leveraging telemetry data like never before. Working knowledge of Python programming is assumed for the example applications that you’ll be building and instrumenting using the OpenTelemetry API and SDK. Some familiarity with Go programming, Linux, and Docker is preferable to help you set up additional components in various examples throughout the book.

Table of contents

  1. Cloud-Native Observability with OpenTelemetry
  2. Foreword
  3. Contributors
  4. About the author
  5. About the reviewer
  6. Preface
    1. Who this book is for
    2. What this book covers
    3. To get the most out of this book
    4. Download the example code files
    5. Download the color images
    6. Conventions used
    7. Get in touch
    8. Share Your Thoughts
  7. Section 1: The Basics
  8. Chapter 1: The History and Concepts of Observability
    1. Understanding cloud-native applications
    2. Looking at the shift to DevOps
    3. Reviewing the history of observability
      1. Centralized logging
      2. Using metrics and dashboards
      3. Applying tracing and analysis
    4. Understanding the history of OpenTelemetry
      1. OpenTracing
      2. OpenCensus
      3. Observability for cloud-native software
    5. Understanding the concepts of OpenTelemetry
      1. Signals
      2. Pipelines
      3. Resources
      4. Context propagation
    6. Summary
  9. Chapter 2: OpenTelemetry Signals – Traces, Metrics, and Logs
    1. Technical requirements
    2. Traces
      1. Anatomy of a trace
      2. Details of a span
      3. Additional considerations
    3. Metrics
      1. Anatomy of a metric
      2. Data point types
      3. Exemplars
      4. Additional considerations
    4. Logs
      1. Anatomy of a log
      2. Correlating logs
      3. Additional considerations
      4. Semantic conventions
    5. Summary
  10. Chapter 3: Auto-Instrumentation
    1. Technical requirements
    2. What is auto-instrumentation?
      1. Challenges of manual instrumentation
      2. Components of auto-instrumentation
      3. Limits of auto-instrumentation
    3. Bytecode manipulation
      1. OpenTelemetry Java agent
    4. Runtime hooks and monkey patching
      1. Instrumenting libraries
      2. The Instrumentor interface
      3. Wrapper script
    5. Summary
  11. Section 2: Instrumenting an Application
  12. Chapter 4: Distributed Tracing – Tracing Code Execution
    1. Technical requirements
    2. Configuring the tracing pipeline
      1. Getting a tracer
    3. Generating tracing data
      1. The Context API
      2. Span processors
    4. Enriching the data
      1. ResourceDetector
      2. Span attributes
      3. SpanKind
    5. Propagating context
      1. Additional propagator formats
      2. Composite propagator
    6. Recording events, exceptions, and status
      1. Events
      2. Exceptions
      3. Status
    7. Summary
  13. Chapter 5: Metrics – Recording Measurements
    1. Technical requirements
    2. Configuring the metrics pipeline
      1. Obtaining a meter
      2. Push-based and pull-based exporting
    3. Choosing the right OpenTelemetry instrument
      1. Counter
      2. Asynchronous counter
      3. An up/down counter
      4. Asynchronous up/down counter
      5. Histogram
      6. Asynchronous gauge
      7. Duplicate instruments
    4. Customizing metric outputs with views
      1. Filtering
      2. Dimensions
      3. Aggregation
    5. The grocery store
      1. Number of requests
      2. Request duration
      3. Concurrent requests
      4. Resource consumption
    6. Summary
  14. Chapter 6: Logging – Capturing Events
    1. Technical requirements
    2. Configuring OpenTelemetry logging
    3. Producing logs
      1. Using LogEmitter
      2. The standard logging library
    4. A logging signal in practice
      1. Distributed tracing and logs
      2. OpenTelemetry logging with Flask
      3. Logging with WSGI middleware
      4. Resource correlation
    5. Summary
  15. Chapter 7: Instrumentation Libraries
    1. Technical requirements
    2. Auto-instrumentation configuration
      1. OpenTelemetry distribution
      2. OpenTelemetry configurator
      3. Environment variables
      4. Command-line options
    3. Requests library instrumentor
      1. Additional configuration options
      2. Manual invocation
      3. Double instrumentation
    4. Automatic configuration
      1. Configuring resource attributes
      2. Configuring traces
      3. Configuring metrics
      4. Configuring logs
      5. Configuring propagation
    5. Revisiting the grocery store
      1. Legacy inventory
      2. Grocery store
      3. Shopper
    6. Flask library instrumentor
      1. Additional configuration options
    7. Finding instrumentation libraries
      1. OpenTelemetry registry
      2. opentelemetry-bootstrap
    8. Summary
  16. Section 3: Using Telemetry Data
  17. Chapter 8: OpenTelemetry Collector
    1. Technical requirements
    2. The purpose of OpenTelemetry Collector
    3. Understanding the components of OpenTelemetry Collector
      1. Receivers
      2. Processors
      3. Exporters
      4. Extensions
      5. Additional components
    4. Transporting telemetry via OTLP
      1. Encodings and protocols
      2. Additional design considerations
    5. Using OpenTelemetry Collector
      1. Configuring the exporter
      2. Configuring the collector
      3. Modifying spans
      4. Filtering metrics
    6. Summary
  18. Chapter 9: Deploying the Collector
    1. Technical requirements
    2. Collecting application telemetry
      1. Deploying the sidecar
    3. System-level telemetry
      1. Deploying the agent
      2. Connecting the sidecar and the agent
      3. Adding resource attributes
    4. Collector as a gateway
      1. Autoscaling
      2. OpenTelemetry Operator
    5. Summary
  19. Chapter 10: Configuring Backends
    1. Technical requirements
    2. Backend options for analyzing telemetry data
      1. Tracing
      2. Metrics
      3. Logging
    3. Running in production
      1. High availability
      2. Scalability
      3. Data retention
      4. Privacy regulations
    4. Summary
  20. Chapter 11: Diagnosing Problems
    1. Technical requirements
    2. Introducing a little chaos
      1. Experiment #1 – increased latency
      2. Experiment #2 – resource pressure
      3. Experiment #3 – unexpected shutdown
    3. Using telemetry first to answer questions
    4. Summary
  21. Chapter 12: Sampling
    1. Technical requirements
    2. Concepts of sampling across signals
      1. Traces
      2. Metrics
      3. Logs
      4. Sampling strategies
      5. Samplers available
    3. Sampling at the application level via the SDK
    4. Using the OpenTelemetry Collector to sample data
      1. Tail sampling processor
    5. Summary
    6. Why subscribe?
  22. Other Books You May Enjoy
    1. Packt is searching for authors like you
    2. Share Your Thoughts

Product information

  • Title: Cloud-Native Observability with OpenTelemetry
  • Author(s): Alex Boten
  • Release date: May 2022
  • Publisher(s): Packt Publishing
  • ISBN: 9781801077705