Skip to content

API and SDK Separation, Providers and Plugin Interfaces: OTCA practice questions

OpenTelemetry splits each signal into an API and an SDK so that instrumentation never depends on a particular implementation. Libraries and frameworks reference only the API packages, and the spec overview says instrumentation authors must not directly reference any SDK package. The application owner decides whether to install the SDK, which exporters to use and how to configure everything else.

By Ibrahim Yesilay · Published · Updated

Independent community practice, not affiliated with or endorsed by CNCF or The Linux Foundation.

What API and SDK Separation, Providers and Plugin Interfaces covers in OTCA

OpenTelemetry splits each signal into an API and an SDK so that instrumentation never depends on a particular implementation. Libraries and frameworks reference only the API packages, and the spec overview says instrumentation authors must not directly reference any SDK package. The application owner decides whether to install the SDK, which exporters to use and how to configure everything else. Without an SDK the API stays functional but records nothing. Even then, a span created from a context that holds a remote parent is returned as a non-recording span carrying that parent's SpanContext, so trace context still flows to outgoing calls.

Providers are the entry points for each signal: TracerProvider, MeterProvider and LoggerProvider. The API should offer a way to register and read a global default provider, but an application may also create several provider instances, for example to give different span processors to different parts of a program. Configuration lives in the provider rather than in individual Tracers or Meters. The Tracing API also requires that users never have to obtain a Tracer again just to pick up configuration changes.

The SDK exposes two kinds of public surface that are not part of the API. Application owners use SDK constructors, and plugin authors use SDK plugin interfaces. On the tracing side the extension points include span processors, samplers, span exporters and ID generators. A sampler implements ShouldSample and returns DROP, RECORD_ONLY or RECORD_AND_SAMPLE, plus attributes and a Tracestate. The ID generator lets a vendor supply custom trace and span IDs; vendor-specific generators such as an AWS X-Ray one must not be shipped in core packages. Propagators are also pluggable, and the spec treats OTLP exporters and the TraceContext propagator as core packages defined by the specification.

Resources have their own extension point. Resource detectors for platforms such as Docker or Kubernetes, or for cloud vendors, must be published separately from the SDK. They return a resource that is merged into the one associated with a provider. A detector that finds nothing has not failed, but combining detectors whose non-empty Schema URLs differ is an error with an undefined result. On the metrics side, Views let the application owner change which instruments are kept, how they are aggregated and which attribute keys survive, without editing library code. A match-all View with the Drop aggregation disables instruments by default.

Exporters should stay thin. The client design principles ask vendors to implement the SDK exporter interface in a separate package and to rely on SDK helpers for batching, queuing and retry. The same principles describe an in-memory exporter that collects telemetry for unit tests. Optional packages that the project maintains are Contrib: API Contrib depends only on the API, while SDK Contrib also depends on the SDK.

Key points

  • Instrumentation depends only on the API, and the application owner installs and configures the SDK.
  • TracerProvider, MeterProvider and LoggerProvider own configuration, and several instances may exist in one process.
  • Samplers, span processors, exporters, ID generators, propagators and resource detectors are SDK extension points.
  • Vendor-specific components such as an X-Ray ID generator or platform resource detectors live outside the core SDK.
  • Views customize metric output, including disabling instruments with a match-all Drop aggregation.

Three sample questions

21 OTCA questions on API and SDK Separation, Providers and Plugin Interfaces, 21 with explanations. How practice works

Question 1

You need to ensure that all Meters created by a MeterProvider are configured according to specific rules defined at runtime. Which component should you utilize to achieve this within the MeterProvider?
  1. A.MeterConfigurator
  2. B.PeriodicExportingMetricReader
  3. C.Resource
  4. D.MetricExporter

Correct answer: A

The Metrics SDK spec says a MeterConfigurator "is a function which computes the MeterConfig for a Meter" from the Meter's instrumentation scope, and that the MeterProvider "MUST compute the relevant MeterConfig using the configured MeterConfigurator" for every Meter it creates. The MeterConfigurator is part of the MeterProvider's own configuration and is marked Development in the spec. Why the other options are wrong. "PeriodicExportingMetricReader": a MetricReader collects metrics and passes them to an exporter on a schedule; it does not decide how each Meter is configured. "Resource": a Resource describes the entity producing telemetry; it carries attributes, not per-Meter rules. "MetricExporter": a MetricExporter only sends collected metrics to a destination; it has no say in how Meters behave.

Sources: OpenTelemetry spec: Metrics SDK, OpenTelemetry spec: Overview

Question 2

Which characteristic distinguishes the OpenTelemetry API from the SDK in terms of stability?
  1. A.The API has more frequent updates compared to the SDK.
  2. B.The SDK is more stable with less frequent updates compared to the API.
  3. C.Both API and SDK have similar stability and update frequencies.
  4. D.The API is more stable with less frequent updates compared to the SDK.

Correct answer: D

The versioning and stability spec says the API of a signal "MUST become stable before the other components", treats backwards compatibility of the API as a strict requirement because the API is embedded in widely shared libraries, and asks for major API versions to be supported for at least three years after the next major release, against at least one year for the SDK. The API is therefore the more stable, slower-moving part. Why the other options are wrong. "The API has more frequent updates compared to the…": the spec aims for the opposite: the API changes slowly so that shared libraries never break. "The SDK is more stable with less frequent updates…": the SDK has the shorter support window (one year versus three for the API) and gains features more often. "Both API and SDK have similar stability and update…": the spec gives the API and the SDK different stability rules and different support periods.

Sources: OpenTelemetry spec: Versioning and stability for OpenTelemetry clients, OpenTelemetry docs: Libraries

Question 3

You are developing a library that needs to instrument various web frameworks without directly depending on the OpenTelemetry SDK. Which OpenTelemetry component should you use for instrumentation?
  1. A.OpenTelemetry Collector
  2. B.OpenTelemetry API
  3. C.OpenTelemetry Instrumentation Libraries
  4. D.OpenTelemetry SDK

Correct answer: B

The Libraries page says "Libraries should only use the OpenTelemetry API", and that unless the application imports the SDK, the instrumentation does nothing and has no performance impact. The library guidelines say the application, not the library, takes the dependency on the SDK. Why the other options are wrong. "OpenTelemetry Collector": the Collector is a separate service that receives telemetry; a library does not instrument code with it. "OpenTelemetry Instrumentation Libraries": instrumentation libraries are separate packages that are themselves built on the API; native instrumentation in your own library calls the API directly. "OpenTelemetry SDK": depending on the SDK is what the library must avoid; the application chooses and configures the SDK.

Sources: OpenTelemetry docs: Libraries, OpenTelemetry spec: Library guidelines

Practice this topic

Focus mode keeps every question on API and SDK Separation, Providers and Plugin Interfaces until you leave it. 10 free guest answers, then a free account; no credit card.

Or open OTCA practice across all topics.

Sources

The explanation above was checked against these official documents.

Frequently asked questions

Who uses the SDK plugin interfaces?

Plugin authors, such as people writing a custom exporter, sampler or processor. Application owners use SDK constructors, and instrumentation authors use only the API.

What happens to an instrumented library when no SDK is installed?

It keeps working. API calls return valid objects, nothing is recorded or exported, and a parent SpanContext found in the context is still passed on so propagation is not broken.