Line data Source code
1 : #pragma once 2 : 3 : // This component provides an interface, `Collector`, to which spans of 4 : // completed trace segments can be sent. 5 : // 6 : // `DatadogAgent`, defined in `datadog_agent.h`, implements `Collector` by 7 : // serializing the spans and sending them to a Datadog Agent. 8 : // 9 : // As a result of `send`ing spans to a `Collector`, the `TraceSampler` might be 10 : // adjusted to increase or decrease the rate at which traces are kept. See the 11 : // `response_handler` parameter to `Collector::send`. 12 : 13 : #include <memory> 14 : #include <vector> 15 : 16 : #include "expected.h" 17 : #include "json_fwd.hpp" 18 : #include "optional.h" 19 : 20 : namespace datadog { 21 : namespace tracing { 22 : 23 : struct SpanData; 24 : class TraceSampler; 25 : 26 : class Collector { 27 : public: 28 : // Submit ownership of the specified `spans` to the collector. If the 29 : // collector delivers a response relevant to trace sampling, reconfigure the 30 : // sampler using the specified `response_handler`. Return an error if one 31 : // occurs. 32 : virtual Expected<void> send( 33 : std::vector<std::unique_ptr<SpanData>>&& spans, 34 : const std::shared_ptr<TraceSampler>& response_handler) = 0; 35 : 36 : // Return a JSON representation of this object's configuration. The JSON 37 : // representation is an object with the following properties: 38 : // 39 : // - "type" is the unmangled, qualified name of the most-derived class, e.g. 40 : // "datadog::tracing::DatadogAgent". 41 : // - "config" is an object containing this object's configuration. "config" 42 : // may be omitted if the derived class has no configuration. 43 : virtual nlohmann::json config_json() const = 0; 44 : 45 631 : virtual ~Collector() {} 46 : }; 47 : 48 : } // namespace tracing 49 : } // namespace datadog