Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ cc_library(
"include/datadog/telemetry/configuration.h",
"include/datadog/telemetry/metrics.h",
"include/datadog/telemetry/telemetry.h",
"include/datadog/telemetry/product.h",
"include/datadog/remote_config/capability.h",
"include/datadog/remote_config/listener.h",
"include/datadog/remote_config/product.h",
Expand Down
5 changes: 4 additions & 1 deletion include/datadog/environment.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,10 @@ namespace environment {
MACRO(DD_TELEMETRY_DEBUG) \
MACRO(DD_TRACE_BAGGAGE_MAX_ITEMS) \
MACRO(DD_TRACE_BAGGAGE_MAX_BYTES) \
MACRO(DD_TELEMETRY_LOG_COLLECTION_ENABLED)
MACRO(DD_TELEMETRY_LOG_COLLECTION_ENABLED) \
MACRO(DD_INSTRUMENTATION_INSTALL_ID) \
MACRO(DD_INSTRUMENTATION_INSTALL_TYPE) \
MACRO(DD_INSTRUMENTATION_INSTALL_TIME)

#define WITH_COMMA(ARG) ARG,

Expand Down
12 changes: 12 additions & 0 deletions include/datadog/telemetry/configuration.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
#pragma once

#include <datadog/config.h>
#include <datadog/expected.h>
#include <datadog/optional.h>
#include <datadog/telemetry/product.h>

#include <chrono>
#include <string>
#include <vector>

namespace datadog::telemetry {

Expand Down Expand Up @@ -38,6 +41,8 @@ struct Configuration {
// Can be overriden by the `DD_TELEMETRY_LOG_COLLECTION_ENABLED` environment
// variable.
tracing::Optional<bool> report_logs;
// List of products reported in the `app-started` message.
std::vector<Product> products;
};

struct FinalizedConfiguration {
Expand All @@ -49,6 +54,13 @@ struct FinalizedConfiguration {
std::chrono::steady_clock::duration heartbeat_interval;
std::string integration_name;
std::string integration_version;
std::vector<Product> products;

// Onboarding metadata coming from `DD_INSTRUMENTATION_INSTALL_*` environment
// variables.
tracing::Optional<std::string> install_id;
tracing::Optional<std::string> install_type;
tracing::Optional<std::string> install_time;

friend tracing::Expected<FinalizedConfiguration> finalize_config(
const Configuration&);
Expand Down
57 changes: 57 additions & 0 deletions include/datadog/telemetry/product.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#pragma once

#include <datadog/config.h>
#include <datadog/optional.h>

#include <string>
#include <unordered_map>

namespace datadog::telemetry {

/// Represents a single product and its associated metadata.
struct Product final {
enum class Name : char {
tracing,
appsec,
profiler,
mlobs,
live_debugger,
rum,
};

/// The product name identifier from one of the possible values above.
Name name;
/// Flag indicating if the product is currently enabled.
bool enabled;
/// The version string of the product.
std::string version;
/// Optional error code related to the product status.
tracing::Optional<int> error_code;
/// Optional error message related to the product status.
tracing::Optional<std::string> error_message;
/// Map of configuration settings for the product.
std::unordered_map<tracing::ConfigName, tracing::ConfigMetadata>
configurations;
};

inline std::string_view to_string(Product::Name product) {
switch (product) {
case Product::Name::tracing:
return "tracing";
case Product::Name::appsec:
return "appsec";
case Product::Name::profiler:
return "profiler";
case Product::Name::mlobs:
return "mlobs";
case Product::Name::live_debugger:
return "live_debugger";
case Product::Name::rum:
return "rum";
}

// unreachable.
return "";
}

} // namespace datadog::telemetry
21 changes: 3 additions & 18 deletions include/datadog/telemetry/telemetry.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#include <datadog/telemetry/metrics.h>

#include <memory>
#include <unordered_map>
#include <vector>

/// Telemetry functions are responsibles for handling internal telemetry data to
Expand All @@ -19,8 +18,9 @@
namespace datadog::telemetry {

/// Initialize the telemetry module
/// Once initialized, the telemetry module is running for the entier lifecycle
/// of the application.
/// Once initialized, sends a notification indicating that the application has
/// started. The telemetry module is running for the entire lifecycle of the
/// application.
///
/// @param configuration The finalized configuration settings.
/// @param logger User logger instance.
Expand All @@ -36,21 +36,6 @@ void init(FinalizedConfiguration configuration,
tracing::HTTPClient::URL agent_url,
tracing::Clock clock = tracing::default_clock);

/// Sends a notification indicating that the application has started.
///
/// This function is responsible for reporting the application has successfully
/// started. It takes a configuration map as a parameter, which contains various
/// configuration settings helping to understand how our product are used.
///
/// @param conf A map containing configuration names and their corresponding
/// metadata.
///
/// @note This function should be called after the application has completed its
/// initialization process to ensure that all components are aware of the
/// application's startup status.
void send_app_started(const std::unordered_map<tracing::ConfigName,
tracing::ConfigMetadata>& conf);

/// Sends configuration changes.
///
/// This function is responsible for sending reported configuration changes
Expand Down
16 changes: 16 additions & 0 deletions src/datadog/telemetry/configuration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,22 @@ tracing::Expected<FinalizedConfiguration> finalize_config(
pick(env_config->integration_version, user_config.integration_version,
tracing::tracer_version);

// products
result.products = user_config.products;

// onboarding data
if (auto install_id = lookup(environment::DD_INSTRUMENTATION_INSTALL_ID)) {
result.install_id = std::string(*install_id);
}
if (auto install_type =
lookup(environment::DD_INSTRUMENTATION_INSTALL_TYPE)) {
result.install_type = std::string(*install_type);
}
if (auto install_time =
lookup(environment::DD_INSTRUMENTATION_INSTALL_TIME)) {
result.install_time = std::string(*install_time);
}

return result;
}

Expand Down
10 changes: 0 additions & 10 deletions src/datadog/telemetry/telemetry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,6 @@ void init(FinalizedConfiguration configuration,
agent_url, clock});
}

void send_app_started(const std::unordered_map<tracing::ConfigName,
tracing::ConfigMetadata>& conf) {
std::visit(
details::Overload{
[&](Telemetry& telemetry) { telemetry.send_app_started(conf); },
[](NoopTelemetry) {},
},
instance());
}

void send_configuration_change() {
std::visit(
details::Overload{
Expand Down
Loading