LCOV - code coverage report
Current view: top level - datadog - datadog_agent_config.h (source / functions) Hit Total Coverage
Test: filtered.info Lines: 1 1 100.0 %
Date: 2024-01-03 20:30:12 Functions: 1 1 100.0 %

          Line data    Source code
       1             : #pragma once
       2             : 
       3             : // This component provides facilities for configuring a `DatadogAgent`.
       4             : //
       5             : // `struct DatadogAgentConfig` contains fields that are used to configure
       6             : // `DatadogAgent`.  The configuration must first be finalized before it can be
       7             : // used by `DatadogAgent`.  The function `finalize_config` produces either an
       8             : // error or a `FinalizedDatadogAgentConfig`.  The latter can be used by
       9             : // `DatadogAgent`.
      10             : //
      11             : // Typical usage of `DatadogAgentConfig` is implicit as part of `TracerConfig`.
      12             : // See `tracer_config.h`.
      13             : 
      14             : #include <chrono>
      15             : #include <memory>
      16             : #include <string>
      17             : #include <variant>
      18             : 
      19             : #include "clock.h"
      20             : #include "expected.h"
      21             : #include "http_client.h"
      22             : #include "string_view.h"
      23             : 
      24             : namespace datadog {
      25             : namespace tracing {
      26             : 
      27             : class EventScheduler;
      28             : class Logger;
      29             : 
      30             : struct DatadogAgentConfig {
      31             :   // The `HTTPClient` used to submit traces to the Datadog Agent.  If this
      32             :   // library was built with libcurl (the default), then `http_client` is
      33             :   // optional: a `Curl` instance will be used if `http_client` is left null.
      34             :   // If this library was built without libcurl, then `http_client` is required
      35             :   // not to be null.
      36             :   std::shared_ptr<HTTPClient> http_client;
      37             :   // The `EventScheduler` used to periodically submit batches of traces to the
      38             :   // Datadog Agent.  If `event_scheduler` is null, then a
      39             :   // `ThreadedEventScheduler` instance will be used instead.
      40             :   std::shared_ptr<EventScheduler> event_scheduler = nullptr;
      41             :   // A URL at which the Datadog Agent can be contacted.
      42             :   // The following formats are supported:
      43             :   //
      44             :   // - http://<domain or IP>:<port>
      45             :   // - http://<domain or IP>
      46             :   // - http+unix://<path to socket>
      47             :   // - unix://<path to socket>
      48             :   //
      49             :   // The port defaults to 8126 if it is not specified.
      50             :   std::string url = "http://localhost:8126";
      51             :   // How often, in milliseconds, to send batches of traces to the Datadog Agent.
      52             :   int flush_interval_milliseconds = 2000;
      53             :   // Maximum amount of time an HTTP request is allowed to run.
      54             :   int request_timeout_milliseconds = 2000;
      55             :   // Maximum amount of time the process is allowed to wait before shutting down.
      56             :   int shutdown_timeout_milliseconds = 2000;
      57             :   // How often, in seconds, to query the Datadog Agent for remote configuration
      58             :   // updates.
      59             :   int remote_configuration_poll_interval_seconds = 5;
      60             : 
      61             :   static Expected<HTTPClient::URL> parse(StringView);
      62             : };
      63             : 
      64             : class FinalizedDatadogAgentConfig {
      65             :   friend Expected<FinalizedDatadogAgentConfig> finalize_config(
      66             :       const DatadogAgentConfig&, const std::shared_ptr<Logger>&, const Clock&);
      67             : 
      68         619 :   FinalizedDatadogAgentConfig() = default;
      69             : 
      70             :  public:
      71             :   Clock clock;
      72             :   std::shared_ptr<HTTPClient> http_client;
      73             :   std::shared_ptr<EventScheduler> event_scheduler;
      74             :   HTTPClient::URL url;
      75             :   std::chrono::steady_clock::duration flush_interval;
      76             :   std::chrono::steady_clock::duration request_timeout;
      77             :   std::chrono::steady_clock::duration shutdown_timeout;
      78             :   std::chrono::steady_clock::duration remote_configuration_poll_interval;
      79             : };
      80             : 
      81             : Expected<FinalizedDatadogAgentConfig> finalize_config(
      82             :     const DatadogAgentConfig& config, const std::shared_ptr<Logger>& logger,
      83             :     const Clock& clock);
      84             : 
      85             : }  // namespace tracing
      86             : }  // namespace datadog

Generated by: LCOV version 1.16