-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[part 1] refactor!: expose telemetry module (#166)
Part 1 of the telemetry module refactoring is to make the telemetry module publicly usable by other Datadog products without any dependencies on the tracer. Changes: - Replace `report_telemetry` configuration with telemetry configuration struct. - Add support for telemetry environment variables. - Implement unit tests
- Loading branch information
Showing
26 changed files
with
616 additions
and
175 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#pragma once | ||
|
||
#include <datadog/expected.h> | ||
#include <datadog/optional.h> | ||
|
||
#include <chrono> | ||
#include <string> | ||
|
||
namespace datadog::telemetry { | ||
|
||
struct Configuration { | ||
// Turn on or off telemetry module | ||
// Enabled by default. | ||
// Overwritten by `DD_INSTRUMENTATION_TELEMETRY_ENABLED` env var. | ||
tracing::Optional<bool> enabled; | ||
// Turn on or off metrics reporting | ||
// Overwritten by `DD_TELEMETRY_METRICS_ENABLED` env var. | ||
tracing::Optional<bool> report_metrics; | ||
// Interval of metrics payload | ||
// Overwritten by `DD_TELEMETRY_METRICS_INTERVAL_SECONDS` env var. | ||
tracing::Optional<int> metrics_interval_seconds; | ||
// Interval of heartbeat payload | ||
// Overwritten by `DD_TELEMETRY_HEARTBEAT_INTERVAL` env var. | ||
tracing::Optional<int> heartbeat_interval_seconds; | ||
// `integration_name` is the name of the product integrating this library. | ||
// Example: "nginx", "envoy" or "istio". | ||
tracing::Optional<std::string> integration_name; | ||
// `integration_version` is the version of the product integrating this | ||
// library. | ||
// Example: "1.2.3", "6c44da20", "2020.02.13" | ||
tracing::Optional<std::string> integration_version; | ||
}; | ||
|
||
struct FinalizedConfiguration { | ||
bool debug; | ||
bool enabled; | ||
bool report_metrics; | ||
std::chrono::steady_clock::duration metrics_interval; | ||
std::chrono::steady_clock::duration heartbeat_interval; | ||
std::string integration_name; | ||
std::string integration_version; | ||
|
||
friend tracing::Expected<FinalizedConfiguration> finalize_config( | ||
const Configuration&); | ||
}; | ||
|
||
tracing::Expected<FinalizedConfiguration> finalize_config( | ||
const Configuration& = Configuration{}); | ||
|
||
} // namespace datadog::telemetry |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#pragma once | ||
|
||
#include <datadog/logger.h> | ||
#include <datadog/telemetry/configuration.h> | ||
#include <datadog/telemetry/metrics.h> | ||
|
||
#include <memory> | ||
#include <vector> | ||
|
||
namespace datadog { | ||
|
||
namespace tracing { | ||
class DatadogAgent; | ||
class TracerTelemetry; | ||
} // namespace tracing | ||
|
||
namespace telemetry { | ||
|
||
class Telemetry { | ||
FinalizedConfiguration config_; | ||
std::shared_ptr<tracing::Logger> logger_; | ||
|
||
std::shared_ptr<tracing::DatadogAgent> datadog_agent_; | ||
std::shared_ptr<tracing::TracerTelemetry> tracer_telemetry_; | ||
|
||
public: | ||
Telemetry(FinalizedConfiguration configuration, | ||
std::shared_ptr<tracing::Logger> logger, | ||
std::vector<std::shared_ptr<Metric>> metrics); | ||
|
||
~Telemetry() = default; | ||
}; | ||
|
||
} // namespace telemetry | ||
} // namespace datadog |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.