跪拜 Guibai
← Back to the summary

OpenTelemetry: The Standard Data Collection Layer for Distributed Systems

1. Introduction

As microservices, Kubernetes, real-time computing platforms, and AI applications enter production, system problems rarely occur within a single process or on a single machine. A single interface timeout can involve an API gateway, authentication service, Kafka, Flink jobs, database, cache, object storage, and downstream analytics systems. Traditional monitoring relying on scattered logs, metrics, and tracing tools often sees only local symptoms and struggles to reconstruct the full causal chain.

OpenTelemetry emerged in this context. It is an open-source, vendor-neutral observability framework and toolset for generating, collecting, processing, and exporting telemetry data such as traces, metrics, and logs. It is not a storage or visualization backend itself; instead, it standardizes the data collection layer between applications and backends, making it easier to instrument applications and systems while avoiding locking into a specific observability backend.

OpenTelemetry overview diagram

2. Core Positioning

The first layer of OpenTelemetry's positioning is "standard." It defines APIs, SDKs, the OTLP protocol, semantic conventions, automatic instrumentation, the Collector, and other components. It is an observability framework and toolset for generating, exporting, and collecting telemetry data, supporting traces, metrics, logs, and other data types.

The second layer is the "collection pipeline." OpenTelemetry is not responsible for long-term storage, querying, or graphical display; backends remain the job of Prometheus, Jaeger, Grafana, OpenSearch, ClickHouse, commercial APM, or cloud vendor services.

It can be placed in the system as follows:

+-------------------+       +-----------------------+       +------------------------+
| Application / Job |       | OpenTelemetry Layer   |       | Observability Backend  |
|-------------------|       |-----------------------|       |------------------------|
| API Service       | ----> | API / SDK / Agent     | ----> | Jaeger / Tempo         |
| Flink Job         | ----> | Collector Pipeline    | ----> | Prometheus / Mimir     |
| Kafka Consumer    | ----> | OTLP / Receivers      | ----> | Loki / OpenSearch      |
| Batch Scheduler   | ----> | Processors / Exporter | ----> | Vendor APM / Cloud Obs |
+-------------------+       +-----------------------+       +------------------------+
      Generate signals                 Standardize, process, forward                   Store, query, display

3. Architecture Principles

OpenTelemetry clients are organized by signal. At the highest level, OpenTelemetry clients are organized into signals, where different signals provide different forms of observability, such as tracing, metrics, and baggage. These signals share context propagation but are relatively independent in functionality.

A typical OpenTelemetry architecture can be broken into five layers: application instrumentation layer, SDK layer, protocol layer, Collector layer, and backend layer.

+--------------------------------------------------------------+
|                         User System                          |
+--------------------------------------------------------------+

      [1] Instrumentation
          Manual / Auto / Framework Integration
                  |
                  v
      [2] OpenTelemetry API + SDK
          Span / Metric / LogRecord / Resource / Context
                  |
                  v
      [3] Exporter / OTLP
          gRPC / HTTP to send telemetry data
                  |
                  v
      [4] OpenTelemetry Collector
          Receivers -> Processors -> Exporters
                  |
                  v
      [5] Backend
          Storage / Query / Alerting / Dashboard / Root Cause Analysis

There is a clear division of labor between the OpenTelemetry API and SDK. The API is a cross-cutting public interface for instrumentation; third-party libraries and application code depend on the API. The SDK is an implementation of the API provided by OpenTelemetry, installed and managed by the application owner. This allows library authors to depend only on the stable API without forcing business applications to bind to a specific SDK or backend.

4. Signal Model

OpenTelemetry currently supports traces, metrics, logs, and baggage, and lists events and profiles as in development or proposal stages.

Signal Intuitive Meaning Typical Questions Big Data Scenario Example
Traces Path of a request or task Where is it slow, what is called, where did it fail? Full chain of a data service API calling Spark/Flink/Kafka/storage
Metrics Runtime numeric measurements What is the trend, is a threshold exceeded? Consumption lag, throughput, failure rate, job latency, JVM memory
Logs Event records What specific event happened? Job exception stack, SQL execution error, data quality validation failure
Baggage Key-value info propagated with context How to carry business context across services? tenant_id, pipeline_id, dataset_id, trace dimension labels
Profiles Code-level resource usage records Where are CPU/memory hot spots? High-cost UDFs, serialization hotspots, operator performance bottlenecks

Traces most easily demonstrate OpenTelemetry's value for distributed systems. A trace can be understood as a directed acyclic graph made of spans, where parent-child relationships express call causality.

Trace: A data query request

[HTTP /query API]
        |
        +--> [Auth Service]
        |
        +--> [Query Planner]
        |         |
        |         +--> [Metadata Service]
        |
        +--> [Execution Engine]
                  |
                  +--> [Kafka Read]
                  |
                  +--> [Flink SQL Job]
                  |
                  +--> [Object Storage Scan]

5. Collector Pipeline

The OpenTelemetry Collector is one of the most critical components for real deployments. It is an executable that receives, processes, and exports telemetry data to multiple targets, such as observability backends; it supports many open-source protocols and can be extended with a pluggable architecture.

The core of the Collector is the pipeline. Each pipeline consists of receivers, processors, and exporters, which are responsible for receiving, processing, and exporting data. Pipelines can be used for traces, metrics, and logs, and the receiver, processor, and exporter used must support the corresponding data type; otherwise, the configuration will fail to load.

                     +-----------------------------+
                     | OpenTelemetry Collector     |
                     |-----------------------------|
    App / Agent ---> | Receiver                    |
                     |   otlp / prometheus / ...   |
                     |             |               |
                     |             v               |
                     | Processor                   |
                     |   batch / memory_limiter    |
                     |   attributes / sampling     |
                     |             |               |
                     |             v               |
                     | Exporter                    |
                     |   otlp / prometheus / debug |
                     +-------------|---------------+
                                   v
                          Backend / Data Platform

A common configuration pattern: applications send traces, metrics, and logs to the Collector via OTLP. The Collector uses memory_limiter to control memory, batch to merge and batch sends, and different exporters to forward data to backends. For big data platforms, this pipeline design resembles the "ingest, clean, route, sink" approach of data collection pipelines.

6. Instrumentation Methods

OpenTelemetry supports two main types of instrumentation: code-based and zero-code. Code-based instrumentation can obtain deeper, richer telemetry from inside the application; zero-code solutions are suitable for quick starts or scenarios where the application code cannot be modified, and both can be used together.

Method Suitable Scenarios
Zero-code auto-instrumentation Quick integration for Web, RPC, DB clients
Code-based manual instrumentation Business-critical paths, data task phases
Framework/library native integration Common components, SDKs, platform middleware
Collector ingestion of external signals Compatible sources like Prometheus, Zipkin

The advantage of auto-instrumentation is fast integration, typically covering common boundaries like HTTP, databases, message queues, and RPC frameworks; its limitation is limited understanding of business semantics.

Manual instrumentation can add business context such as "dataset name," "job ID," "partition count," "data quality rules," and "tenant info" to spans or metrics, but requires engineering discipline to avoid issues like field naming chaos, high label cardinality, and inconsistent sampling policies.

7. Features and Advantages

OpenTelemetry's core features can be summarized as standardization, vendor neutrality, unified multi-signal, context propagation, extensible collector pipeline, and ecosystem integration.

Feature Description Value
Standard API/SDK Each language implementation follows the OpenTelemetry spec Reduces integration differences across languages
OTLP Protocol Standard telemetry data transfer protocol Decouples applications from backends
Semantic Conventions Defines common telemetry field naming Reduces field chaos, improves query consistency
Context Propagation Propagates trace context across services Ties together complete call chains
Collector Pipeline Receives, processes, exports telemetry data Unified collection and routing
Auto-instrumentation Basic telemetry without code changes Lowers initial integration cost
Manual instrumentation Adds business semantics Enables fine-grained diagnostics

The biggest advantage of OpenTelemetry is reducing repeat work and migration costs in building observability: users own their generated data and are not locked to a vendor; users only need to learn one set of APIs and conventions.

For platform teams, this means applications need only be instrumented according to OpenTelemetry standards, and data can later be sent to different backends via the Collector. Today you might use Jaeger for traces, Prometheus for metrics, and OpenSearch for logs; tomorrow you can migrate to a commercial APM or a self-built ClickHouse pipeline without tearing out instrumentation logic from all business code.

For big data teams, OpenTelemetry's other advantage is connecting "system observability" with "data pipeline observability." For example, when a report query becomes slow, traces show which services the request passed through, metrics show Flink or Trino runtime metrics, logs retain exception context, and baggage can carry tenant_id, dataset_id, and job_id through the entire chain. In this way, problem localization no longer depends only on logs from one isolated system.

8. Use Cases

OpenTelemetry is best suited for environments with many services, many languages, complex infrastructure, and diverse backend tools. If the system is small, with only a monolith and simple host monitoring, introducing the full OpenTelemetry stack may still be heavy; but once the system enters the phase of microservices, Kubernetes, multi-cloud, data platforms, or AI workloads, the benefits become clear.

Scenario Appropriate? Reason
Microservice tracing Yes Requests cross multiple services; traces reconstruct causal paths
Kubernetes platform observability Yes Services change dynamically; unified collection and resource dimensions
Big data platform task diagnosis Yes Jobs, queues, datasets, and service dependencies need correlation
Multilingual business systems Yes Standard API/SDK reduces cross-language integration differences
Multi-backend observability architecture Yes Collector can route to different backends
Single large application Depends Integration cost may exceed benefits
Only CPU/memory monitoring Not necessarily Traditional host monitoring may suffice

A typical big data platform usage pattern:

                              +--------------------+
                              |   Grafana / APM    |
                              +----------^---------+
                                         |
    +-------------+     OTLP      +------+------+
    | API Gateway | ------------> | Collector   |
    +-------------+               | Gateway     |
                                  +------+------+
    +-------------+                      ^
    | Flink Jobs  | -------- OTLP -------|
    +-------------+                      |
                                         |
    +-------------+                      |
    | Spark Jobs  | -------- OTLP -------|
    +-------------+                      |
                                         |
    +-------------+                      |
    | Kafka Apps  | -------- OTLP -------|
    +-------------+                      |
                                         v
                               +----------------+
                               | Jaeger/Tempo   |
                               | Prometheus     |
                               | OpenSearch     |
                               +----------------+

9. Deployment and Usage

Common OpenTelemetry Collector deployment modes include No Collector, Agent, Gateway, and Agent + Gateway hybrid. The Collector is a single binary that can be deployed in different ways for different use cases; deployment modes range from direct application-to-backend sending, through an Agent, or through a Gateway to a unified OTLP endpoint.

Mode Structure Advantages Risks
No Collector App -> Backend Simple, fewer components App directly couples to backend, inconsistent policies
Agent App -> Node Agent -> Backend Local collection, reduces app complexity Node resource and configuration management complexity
Gateway App/Agent -> Central Collector -> Backend Unified egress, central processing, good for multiple backends Gateway needs scaling and high availability
Agent + Gateway App -> Agent -> Gateway -> Backend Combines local collection and central governance Longer chain, harder to troubleshoot

In Kubernetes, a common practice is to deploy an Agent Collector as a DaemonSet, with each node responsible for receiving telemetry from applications on that node; then deploy a set of Gateway Collectors for cross-cluster aggregation, sampling, filtering, redaction, routing, and backend export. For big data platforms, this mode suits the pattern of collecting data from Flink, Spark, Trino, Kafka Connect, and similar components locally, then routing it into a unified observability backend.

A pragmatic rollout path can be broken into four steps: establish the minimal pipeline first, then add business semantics, then govern data quality, and finally build platform-wide standards.

Step 1: Ingest basic signals
App -> SDK/Auto Instrumentation -> Collector -> Debug Exporter

Step 2: Connect real backends
Collector -> Jaeger/Tempo/Prometheus/OpenSearch/APM

Step 3: Add business context
service.name / deployment.environment / job_id / dataset / tenant_id

Step 4: Govern sampling and cost
sampling / batch / memory_limiter / attribute filtering

In the first phase, use the debug exporter to verify data reaches the Collector. For configuration validation and network debugging, send a small amount of test data to a Collector configured with local log output, and use the debug exporter to confirm the Collector is receiving, processing, and exporting data.

In the second phase, connect the real backends. Don't turn on all systems, all fields, and all logs at once. Especially in big data platforms, fields like job_id, partition, topic, table, tenant, and user can quickly cause high-cardinality issues, pushing up storage and query costs.

Common OpenTelemetry problems are usually not "can we collect data" but "is the data correct, complete, correlatable, and cost-controlled."

Problem Common Causes Suggestions
Collector receives no data Receiver not enabled, port unreachable, client endpoint wrong Check receiver, pipeline, network policies
Data received but backend empty Exporter misconfigured, backend unreachable, auth failed Use debug exporter to verify segment by segment
Data loss Collector undersized, backend write slow, queue misconfigured Increase resources, enable queue/batch, rate-limit sampling
Collector restarts Memory pressure, missing or misconfigured memory_limiter Configure memory limits and assess load
Broken traces Context not propagated, gateway or message queue not passing trace headers Check propagator and middleware integration
Field chaos No semantic conventions, teams name independently Establish resource and attribute conventions
Cost out of control Too many logs, high label cardinality, poor sampling Control attributes, sampling, filtering, aggregation