The old API we were using for tracing is being deprecated. In addition, KNative is also using OpenTelemetry so it helps propagate traces from KNative, through our server, and back if using with KServe.
Implementation
The core functionality is wrapped into the Trace class which provides simple methods to start and end spans. It also abstracts the implementation of the tracing library away from the user, which was one issue of the previous implementation. Only minor changes were needed to the server where these traces start. As before, the destructor of the Trace object ends all its spans.
For propagation, the server request handlers now attempt to extract context from incoming requests before starting a trace. The context is also injected into the REST response for clients to consume if desired. Since callbacks are used in a client-agnostic manner, this injected context is also exposed through the C++ API as a field in the Response object. This change required moving build_options.hpp to the public API to define whether or not to include tracing-related changes.
Notes
The old API had two kinds of span relationships: parent-child and follows-from. In OpenTelemetry, only the parent-child relationship seems to be supported. I've emulated the previous behavior by starting a span that is the default parent of all spans.
Summary of Changes
Closes #10
Motivation
The old API we were using for tracing is being deprecated. In addition, KNative is also using OpenTelemetry so it helps propagate traces from KNative, through our server, and back if using with KServe.
Implementation
The core functionality is wrapped into the Trace class which provides simple methods to start and end spans. It also abstracts the implementation of the tracing library away from the user, which was one issue of the previous implementation. Only minor changes were needed to the server where these traces start. As before, the destructor of the Trace object ends all its spans.
For propagation, the server request handlers now attempt to extract context from incoming requests before starting a trace. The context is also injected into the REST response for clients to consume if desired. Since callbacks are used in a client-agnostic manner, this injected context is also exposed through the C++ API as a field in the Response object. This change required moving
build_options.hpp
to the public API to define whether or not to include tracing-related changes.Notes
The old API had two kinds of span relationships: parent-child and follows-from. In OpenTelemetry, only the parent-child relationship seems to be supported. I've emulated the previous behavior by starting a span that is the default parent of all spans.