Skip to content

Commit 6e4fcc3

Browse files
bm1549claude
andcommitted
refactor: remove non-native config telemetry reporting
Remove AdditionalConfigEntry and related code. C++ should not report telemetry for configs it doesn't consume (DD_PROFILING_ENABLED, DD_LOGS_INJECTION, etc.). Only configs that go through resolve_and_record_config() are reported in telemetry. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
1 parent c340dcc commit 6e4fcc3

3 files changed

Lines changed: 1 addition & 106 deletions

File tree

include/datadog/telemetry/configuration.h

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#pragma once
22

3-
#include <datadog/config.h>
43
#include <datadog/expected.h>
54
#include <datadog/optional.h>
65
#include <datadog/telemetry/product.h>
@@ -45,18 +44,6 @@ struct Configuration {
4544
std::vector<Product> products;
4645
};
4746

48-
// Represents a configuration entry for a key that is not natively consumed
49-
// by dd-trace-cpp (e.g. DD_LOGS_INJECTION, DD_PROFILING_ENABLED). These
50-
// entries come from stable configuration files and are reported in telemetry
51-
// so that the backend knows about all configured values and their origins.
52-
struct AdditionalConfigEntry {
53-
std::string name; // DD_* key name, used as the telemetry config name
54-
std::string value;
55-
tracing::ConfigMetadata::Origin origin;
56-
tracing::Optional<std::string>
57-
config_id; // fleet policy ID if origin is fleet
58-
};
59-
6047
struct FinalizedConfiguration {
6148
bool debug;
6249
bool enabled;
@@ -68,9 +55,6 @@ struct FinalizedConfiguration {
6855
std::string integration_version;
6956
std::vector<Product> products;
7057

71-
// Non-native stable config entries to include in telemetry.
72-
std::vector<AdditionalConfigEntry> additional_config_entries;
73-
7458
// Onboarding metadata coming from `DD_INSTRUMENTATION_INSTALL_*` environment
7559
// variables.
7660
tracing::Optional<std::string> install_id;

src/datadog/telemetry/telemetry_impl.cpp

Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -599,39 +599,7 @@ std::string Telemetry::app_started_payload() {
599599
/// assumes telemetry event can only be generated from a tracer. The
600600
/// assumption is that the tracing product is always enabled and there
601601
/// is no need to declare it.
602-
if (product.name == Product::Name::tracing) {
603-
// Also emit additional (non-native) stable config entries for this
604-
// product. These use string-based names instead of ConfigName enum.
605-
for (const auto& entry : config_.additional_config_entries) {
606-
auto j = nlohmann::json{
607-
{"name", entry.name}, {"value", entry.value}, {"seq_id", 1}};
608-
switch (entry.origin) {
609-
case tracing::ConfigMetadata::Origin::LOCAL_STABLE_CONFIG:
610-
j["origin"] = "local_stable_config";
611-
break;
612-
case tracing::ConfigMetadata::Origin::FLEET_STABLE_CONFIG:
613-
j["origin"] = "fleet_stable_config";
614-
if (entry.config_id) {
615-
j["config_id"] = *entry.config_id;
616-
}
617-
break;
618-
case tracing::ConfigMetadata::Origin::ENVIRONMENT_VARIABLE:
619-
j["origin"] = "env_var";
620-
break;
621-
case tracing::ConfigMetadata::Origin::CODE:
622-
j["origin"] = "code";
623-
break;
624-
case tracing::ConfigMetadata::Origin::REMOTE_CONFIG:
625-
j["origin"] = "remote_config";
626-
break;
627-
case tracing::ConfigMetadata::Origin::DEFAULT:
628-
j["origin"] = "default";
629-
break;
630-
}
631-
configuration_json.emplace_back(std::move(j));
632-
}
633-
continue;
634-
}
602+
if (product.name == Product::Name::tracing) continue;
635603

636604
auto p = nlohmann::json{
637605
{to_string(product.name),

src/datadog/tracer_config.cpp

Lines changed: 0 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
#include <cassert>
77
#include <string>
88
#include <unordered_map>
9-
#include <unordered_set>
109
#include <vector>
1110

1211
#include "datadog/optional.h"
@@ -561,63 +560,7 @@ Expected<FinalizedTracerConfig> finalize_config(const TracerConfig& user_config,
561560
final_config.collector = user_config.collector;
562561
}
563562

564-
// Build additional config entries for stable config keys that are NOT
565-
// natively consumed by dd-trace-cpp. These are reported in telemetry so
566-
// the backend sees all configured values and their origins.
567-
{
568-
// The set of DD_* keys already handled by the 5-arg
569-
// resolve_and_record_config (which includes stable config sources).
570-
// Keys only handled by the 3-arg version (env+user only) are NOT
571-
// listed here, so their stable config values get picked up below.
572-
static const std::unordered_set<std::string> native_keys = {
573-
"DD_SERVICE",
574-
"DD_ENV",
575-
"DD_VERSION",
576-
"DD_TRACE_STARTUP_LOGS",
577-
"DD_TRACE_ENABLED",
578-
"DD_TRACE_128_BIT_TRACEID_GENERATION_ENABLED",
579-
"DD_APM_TRACING_ENABLED",
580-
};
581-
582-
// Collect all unique keys from both stable configs.
583-
std::unordered_set<std::string> seen_keys;
584-
for (const auto& [key, _] : stable_configs.local.values) {
585-
seen_keys.insert(key);
586-
}
587-
for (const auto& [key, _] : stable_configs.fleet.values) {
588-
seen_keys.insert(key);
589-
}
590563

591-
for (const auto& key : seen_keys) {
592-
if (native_keys.count(key)) continue;
593-
594-
// Determine the winning source.
595-
// Precedence: fleet_stable > local_stable (env not checked for
596-
// non-native keys since dd-trace-cpp doesn't consume them).
597-
auto fleet_val = stable_configs.fleet.lookup(key);
598-
auto local_val = stable_configs.local.lookup(key);
599-
// We don't check actual env vars here for non-native keys because
600-
// dd-trace-cpp doesn't consume them from the environment.
601-
602-
if (fleet_val) {
603-
telemetry::AdditionalConfigEntry entry;
604-
entry.name = key;
605-
entry.value = *fleet_val;
606-
entry.origin = ConfigMetadata::Origin::FLEET_STABLE_CONFIG;
607-
entry.config_id = stable_configs.fleet.config_id;
608-
final_config.telemetry.additional_config_entries.push_back(
609-
std::move(entry));
610-
} else if (local_val) {
611-
telemetry::AdditionalConfigEntry entry;
612-
entry.name = key;
613-
entry.value = *local_val;
614-
entry.origin = ConfigMetadata::Origin::LOCAL_STABLE_CONFIG;
615-
// Local stable config does not have a config_id attached.
616-
final_config.telemetry.additional_config_entries.push_back(
617-
std::move(entry));
618-
}
619-
}
620-
}
621564

622565
return final_config;
623566
}

0 commit comments

Comments
 (0)