Helios is now part of Snyk! Read the full announcement here.

SANDBOX

SECURITY

OBSERVABILITY

LANGUAGES

USE CASES

RESOURCES

What is a Span?

Written by


Subscribe to our Blog

Get the Latest News and Content

What is a span?

At its core, a span represents the lifecycle of a single operation within a system. It serves as a vital building block, offering valuable context and insights into the behavior of applications.

1. What is the role of spans in observability?

Spans let developers track the flow of requests across complex architectures and distributed systems.

As requests propagate through various services, each service generates its span, forming a trace that outlines the complete journey of a request. For example, consider the simple trace diagram extracted from an application with Helios integrated, illustrated below.

Illustrating a trace with Helios
Figure: Illustrating a trace with Helios

2. How are spans generated?

Spans are typically generated and managed by distributed tracing tools or libraries that are integrated into the codebase of each service. These tools automatically instrument the services to capture and propagate span information as requests flow through the system. Popular distributed tracing systems include Helios, Jaeger, and Zipkin.

3. How are spans structured?

Spans are organized hierarchically, comprising root spans, child spans, and potentially more complex structures. Root spans represent the initial request, while child spans represent subsequent operations triggered by the parent span. This hierarchical arrangement aids in understanding the relationships and dependencies between different operations.

4. How do spans help capture latency and performance issues?

By measuring the timestamps of spans, developers can gain insight into the latency and performance of each operation. This information is key for identifying bottlenecks and performance issues within the system.

5. How do spans help in troubleshooting?

Tags and metadata included in spans provide contextual information that helps troubleshoot and diagnose issues. When an error occurs, the associated span can be examined to understand the root cause and which services were involved.

What is the anatomy of a Span?

A span encapsulates crucial information about an operation within a system:

  1. Trace ID: A globally unique identifier connects related spans, forming a distributed trace. This lets developers follow the flow of a specific request as it propagates through various services and components, allowing to trace the end-to-end journey of a particular request.
  2. Span ID: Every span within a distributed trace is assigned a unique Span ID that helps distinguish each span within the same trace. As a result, developers can easily reference and correlate specific spans in a trace, aiding in understanding the sequence of operations and their relationships.
  3. Parent Span ID: This critical component establishes the hierarchical connection between spans. When a process triggers subsequent operations, the resulting spans are considered child spans and inherit the Parent Span ID of the triggering operation. This hierarchical arrangement provides a clear view of how operations are interconnected, making it easier to visualize and comprehend the flow of requests across the app.
  4. Timestamps (start time | end time): Timestamps mark the exact moments when an operation begins and when it concludes. Developers can use the two timestamps to measure the latency of an operator and identify performance issues.
  5. Tags and Metadata: These are additional pieces of contextual information that can be attached to a span. They provide valuable insights into the nature of an operation, including HTTP status codes, error messages, and any custom data that developers wish to associate with the span that lets developers troubleshoot and debug operations, as shown below.
Figure: The anatomy of a span
Figure: The anatomy of a span

Spans in Distributed Tracing

In distributed tracing, “spans” are fundamental units of work that represent individual operations or activities within a distributed system.

Spans let you monitor operations across distributed architectures. Here are top 4 benefits:

  1. Tracking Requests Across Distributed Systems: Every service that operates a distributed system generates its span. These spans then form a distributed trace that’s linked by a Trace ID that lets development teams trace the entire journey of a single request, thus providing better observability.
  2. Capturing Latency and Performance Insights: This information is instrumental in identifying performance bottlenecks, analyzing response times, and optimizing the system’s overall performance.
  3. Context and Troubleshooting: When an error occurs, or an operation behaves unexpectedly, the associated span’s tags and metadata offer valuable insights into the cause of the issue. This context is vital for troubleshooting and debugging distributed systems, helping developers identify the root cause of problems and implement appropriate solutions.
  4. Cross-Service Insights: In distributed systems, requests often involve multiple services working together to fulfill a user’s action. Spans enable developers to gain cross-service insights, allowing them to see the entire sequence of events in processing a single request. This holistic view helps understand the system’s overall health and identify potential points of failure or areas for improvement.

Integrating observability int your application

Spans are crucial for observability in modern software systems. They provide insights into dependencies with their hierarchical structure and interconnected components, and enable tracking requests, analyzing performance, and troubleshooting. Embracing spans ensures robust applications and better observability. Tools like Helios allow you to seamlessly integrate observability into your application with minimal effort, ensuring that your application performance remains optimal.

Subscribe to our Blog

Get the Latest News and Content

About Helios

Helios is an applied observability platform that produces actionable security and monitoring insights. We apply our deep runtime data collection capabilities to help Sec, Dev, and Ops teams understand the actual application risk posture, prioritize vulnerabilities, shorten troubleshooting time, and reduce MTTR.

The Author

Helios
Helios

Helios is an applied observability platform that produces actionable security and monitoring insights. We apply our deep runtime data collection capabilities to help Sec, Dev, and Ops teams understand the actual application risk posture, prioritize vulnerabilities, shorten troubleshooting time, and reduce MTTR.

Related Content

What are microservices
What are Microservices?
Microservices have redefined how developers design, build and deploy mission-critical production software. Therefore, it’s essential to understand...
Read More
eBPF
What is eBPF?
What is eBPF? eBPF, or Extended Berkeley Packet Filter, is a kernel technology available since Linux 4.4. It lets developers run programs without adding...
Read More
What is open telemetry
What is OpenTelemetry (OTel)?
Introduction to OpenTelemetry (OTel) OpenTelemetry is an open-source observability framework designed to collect, instrument, and export telemetry data...
Read More