Splunk Inc.

07/24/2024 | News release | Distributed by Public on 07/24/2024 11:47

What Is OpenTracing

OpenTracing is a project that offers a vendor-neutral API specification designed to track and monitor application requests. When an application functions, various requests progress through different components of a distributed system, such as microservices. OpenTracing is used to monitor such requests to identify application issues such as performance degrades and other bottlenecks. OpenTracing also reduces the burden on developers by providing a standardized way to collect and report trace data.

Today, however, the OpenTracing project is archived. The official website explains that users are now required to migrate to OpenTelemetry, as the OpenTracing project is no longer supported. OpenTelemetry continues the work started by OpenTracing and has expanded upon it by offering a broader and actively supported observability framework.

Let's go in depth with how OpenTracing works, what it did for distrusted tracing, and finally look at migrating to OpenTelemetry.

Evolution of OpenTracing

OpenTracing is a project launched in 2016 with contributions from LightStep and Uber. In the same year, the founder of Lightstep wrote a blog post titled "Toward Turnkey Distributed Tracing". This blog post introduced OpenTracing as a common standard for distributed tracing.

After recognizing the importance of standardizing distributed tracing, the Cloud Native Computing Foundation (CNCF) accepted OpenTracing as its own project and released OpenTracing 1.0.

The CNCF continued to research for better solutions for distributed tracing. As a result, CNCF launched OpenTelemetry in 2019 by merging OpenTracing with another competing project called OpenCensus, which was developed by Google. OpenTelemetry combines and expands the features of both projects under one framework.

(Related reading: our complete guide to OpenTelemetry.)

Distributed tracing & OpenTracing

Distributed tracing is the process of tracking requests as they pass through different components in a distributed system, such as applications built with microservices. Tracing requests in distributed systems has always been difficult and challenging. OpenTracing is an important evolutionary milestone in distributed tracing.

OpenTracing is a framework built on distributed tracing fundamentals. Provided in nine different programming languages, it standardizes the implementation of distributed tracing across different systems. By offering a vendor-neutral API, OpenTracing allows developers to:

  • Instrument their applications consistently.
  • Integrate with various tracing backends without being locked into a specific vendor or platform.

How tracing worked before OpenTracing

Before OpenTracing was introduced, distributed tracing was less standardized. Many organizations had to develop their own tracing systems from scratch. These custom solutions were developed to suit only their own architectures. Custom systems lacked interoperability with other systems or tools outside the organization. Indeed, the cloud era really accelerated the challenges of interoperability.

For the organizations that did not build their own tracing solutions, the alternative was often to adopt vendor-specific tracing tools. While these tools could be powerful, they typically require committing to a particular technology stack or vendor. This restricted the flexibility and increased costs, especially when scaling or transitioning to different technologies.

So, there was no standard approach to tracing.

The results? Different teams within a single organization implemented their tracing differently. This inconsistency created:

  • Compatibility issues
  • Difficulties in aggregating and analyzing trace data across services or microservices

Also, without having a tracing standard, integrating different tools and making them work well together was often a manual and error-prone process. Each new tool or update required significant updates to make them compatible with existing tracing solutions.

What sorts of apps require OpenTracing?

OpenTracing was designed to be useful for complex applications such as those in microservices architectures, distributed systems, and cloud-native environments where tracking requests across multiple components is important.

Also, the OpenTracing framework is essential for asynchronous processing systems, big data applications, and financial platforms that require more insight into data flow and transaction paths.

The importance of OpenTracing

As OpenTracing is vendor-neutral it does not tie developers to any specific tracing system or technology. This flexibility helps organizations to implement any custom or third-party distributed tracing tools that best fit their needs without being restricted by specific network protocols or data formats.

In a microservices architecture, where numerous applications communicate and interact with each other, understanding the flow of requests and diagnosing issues can be messy. OpenTracing provides a standardized way to collect and report trace data across all these services.

  • Tracing requests across your system helps quickly identify the root causes of issues. It saves time and effort in debugging.
  • OpenTracing data can capture performance bottlenecks in your applications. This helps you to plan for future optimization efforts.
  • OpenTracing enables continuous monitoring of your distributed system's health, especially targeting application performance.
  • The open-standard nature of OpenTracing facilitates interoperability with various other tracing tools.

Pros & cons of OpenTracing

Pros Cons
  • Provides a consistent, vendor-neutral API.
  • Developers can switch between different tracing systems without changing the instrumentation code.
  • Provides insights into the system's behavior and performance.
  • Supported by a large community and integrates with many existing tools.
  • Facilitates interoperability between different tracing systems and tools.
  • Implementing can be complex, especially in systems that were not designed with distributed tracing in mind.
  • The quality and behavior of OpenTracing libraries can vary across languages, which may lead to inconsistent tracing data.
  • Adding tracing can introduce overhead in terms of latency and resource consumption.
  • There is a learning curve associated with understanding distributed tracing concepts.
  • It doesn't provide solutions for logging or metric collection.

How OpenTracing Works

We can break down the process used in OpenTracing into several steps.

Step 1: Instrumentation

The first step involves adding instrumentation to the codebase. This means integrating OpenTracing libraries into the application to capture information about operations, such as API calls, database queries, or internal processes.

Developers insert spans at strategic points within their code, which represent specific operations within a larger trace.

Step 2: Creating spans

When a request is made to the application, a trace is initiated, and the first span (often called the root span) is started. As the request moves through various components of the application, additional spans are started and stopped. Each span captures key data such as the start time, end time, and metadata about the operation it represents.

Step 3: Propagation

As the request travels across process boundaries such as between microservices the trace context (which includes trace and span identifiers) is propagated along with it. This is typically done through HTTP headers in web applications. This propagation helps all spans across services to be linked together to form a complete trace.

Step 4: Recording & reporting

Each span records its data, which includes timing information, any errors encountered, and additional metadata. Once a span is completed, it reports this data back to a central tracking system.

Step 5: Visualization & analysis

The collected trace data is processed and visualized in a tracing tool, such as Jaeger or Zipkin. These tools provide a visual representation of the trace. They demonstrate the sequence of span operations across services and how much time each operation took.

OpenTracing architecture

There are several key components of the openTracing Architecture.

Tracer: This is the main component that creates and manages spans. It understands how to serialize and deserialize span information across system boundaries. Handles the tracing data's lifecycle.

Span: Spans are the basic units of work in OpenTracing. They represent the specific operations within the system. Each span captures information such as:

  • The operation name
  • Start and end times
  • Other contextual details

Spans include tags and logs to enrich the trace data with useful metadata and runtime events.

SpanContext: This carries metadata necessary for span propagation across process boundaries. It includes trace and span IDs that uniquely identify each span. SpanContext also contains baggage items and key-value pairs that pass across different spans in the same trace. They help to preserve the state across asynchronous operations.

References: Spans may reference other spans, typically using two types: "ChildOf", indicating direct dependency, and "FollowsFrom", indicating indirect or asynchronous relationships. These references help define the structure of a trace.

Tags and Logs: Tags are key-value pairs attached to spans that label attributes relevant to trace analysis, like HTTP status codes or user IDs. Logs record timestamped events within a span's life. They provide granular insights into the application's behavior at specific moments.

Baggage Items: These are key-value pairs included in the SpanContext that can be accessed across the entire trace and are useful for maintaining state across the system.

(Related reading: What is MELT? Metrics, events, logs & traces.)

How to implement OpenTracing

Implementing OpenTracing in your application involves several key steps.

1. Choose a tracing backend. Decide on a tracing backend that will collect, store, and visualize the traces. Common options include Jaeger, Zipkin, and LightStep.

2. Add OpenTracing libraries. Considering the programming language you are using. Then, add the appropriate OpenTracing libraries to your project. OpenTracing supports multiple programming languages such as Java, Python, JavaScript, Go, etc.

3. Initialize the tracer. Initialize the tracer object in your application. This object is responsible for starting and managing spans. This involves configuring the tracer to communicate with your chosen backend.

4. Instrument your code. Add spans around operations you want to trace.

5. Propagate the context. After implementing basic tracing, run your application and verify that spans are reported correctly to your tracing backend.

6. Increase the scope. Later, you can add more spans, enrich spans with tags and logs for additional context, and use baggage for cross-processing information.

Is OpenTracing dead?

OpenTracing isn't exactly dead. However, it was merged into a more comprehensive framework called OpenTelemetry with the goal of creating a unified, vendor-neutral standard for observability. It covers not just tracing but also metrics and logs. Organizations are encouraged to migrate to OpenTelemetry to benefit from its broader capabilities.

How to migrate from OpenTracing to OpenTelemetry

For users of OpenTracing, migrating to OpenTelemetry is not mandatory, but it's highly recommended - particularly for its active development and broader support.

  1. Start the migration process by reviewing your existing OpenTracing setup. Check which components of the application are instrumented. Then understand what kind of trace data you are collecting.
  2. Research OpenTelemetry's capabilities such as its support for tracing, metrics, and logs. Developers can check the OpenTelemetry official documentation for guidance specific to your programming languages and frameworks.
  3. Identify the changes needed to replace OpenTracing libraries with OpenTelemetry. This might involve updating the instrumentation code, changing configuration settings, and updating how you handle context propagation and span management.
  4. Start by integrating OpenTelemetry into a small, non-critical component of your system to understand its impact and behavior. Then gradually expand the rollout.

As you migrate, compare the new traces with those generated by OpenTracing to make sure that you are capturing the required information. Fine-tune your OpenTelemetry implementation to optimize performance.

Final thoughts

For those seeking options to implement distributed tracing in a new project, starting with OpenTelemetry is advisable. For individuals already utilizing OpenTracing, migrating to OpenTelemetry comes highly recommended.

However, if you want to learn about distributed tracing, OpenTracing would be a good starting point. It will give you a solid understanding of the fundamentals of a vendor-neutral distributed tracing framework. Once you have a proper grasp of OpenTracing, transitioning to OpenTelemetry will be easier.