Skip to content

Commit d6f1328

Browse files
committed
don't use mangled symbol names in startup log
1 parent 51cd7ba commit d6f1328

File tree

11 files changed

+60
-9
lines changed

11 files changed

+60
-9
lines changed

src/datadog/collector.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ class Collector {
3737
// object's configuration. The JSON representation is an object with
3838
// the following properties:
3939
//
40-
// - "type" is the unmangled, unqualified name of the most-derived class, e.g.
41-
// "DatadogAgent".
40+
// - "type" is the unmangled, qualified name of the most-derived class, e.g.
41+
// "datadog::tracing::DatadogAgent".
4242
// - "config" is an object containing this object's configuration. "config"
4343
// may be omitted if the derived class has no configuration.
4444
virtual void config_json(nlohmann::json& destination) const = 0;

src/datadog/curl.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "dict_reader.h"
2020
#include "dict_writer.h"
2121
#include "http_client.h"
22+
#include "json.hpp"
2223
#include "logger.h"
2324
#include "parse_util.h"
2425

@@ -125,6 +126,10 @@ void Curl::drain(std::chrono::steady_clock::time_point deadline) {
125126
impl_->drain(deadline);
126127
}
127128

129+
void Curl::config_json(nlohmann::json &destination) const {
130+
destination = nlohmann::json::object({{"type", "datadog::tracing::Curl"}});
131+
}
132+
128133
CurlImpl::CurlImpl(const std::shared_ptr<Logger> &logger)
129134
: logger_(logger), shutting_down_(false), num_active_handles_(0) {
130135
curl_global_init(CURL_GLOBAL_ALL);

src/datadog/curl.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <string>
1515

1616
#include "http_client.h"
17+
#include "json_fwd.hpp"
1718

1819
namespace datadog {
1920
namespace tracing {
@@ -35,6 +36,8 @@ class Curl : public HTTPClient {
3536
ErrorHandler on_error) override;
3637

3738
void drain(std::chrono::steady_clock::time_point deadline) override;
39+
40+
void config_json(nlohmann::json& destination) const override;
3841
};
3942

4043
} // namespace tracing

src/datadog/datadog_agent.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,15 +169,18 @@ void DatadogAgent::config_json(nlohmann::json& destination) const {
169169
const auto flush_interval_milliseconds =
170170
std::chrono::duration_cast<std::chrono::milliseconds>(flush_interval_)
171171
.count();
172+
nlohmann::json http_client_json, event_scheduler_json;
173+
http_client_->config_json(http_client_json);
174+
event_scheduler_->config_json(event_scheduler_json);
172175

173176
// clang-format off
174177
destination = nlohmann::json::object({
175-
{"type", "DatadogAgent"},
178+
{"type", "datadog::tracing::DatadogAgent"},
176179
{"config", nlohmann::json::object({
177180
{"url", (url.scheme + "://" + url.authority + url.path)},
178181
{"flush_interval_milliseconds", flush_interval_milliseconds},
179-
{"http_client_typeid", typeid(*http_client_).name()},
180-
{"event_scheduler_typeid", typeid(*event_scheduler_).name()},
182+
{"http_client", http_client_json},
183+
{"event_scheduler", event_scheduler_json},
181184
})},
182185
});
183186
// clang-format on

src/datadog/event_scheduler.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include <functional>
1414

1515
#include "error.h"
16+
#include "json_fwd.hpp"
1617

1718
namespace datadog {
1819
namespace tracing {
@@ -29,6 +30,16 @@ class EventScheduler {
2930
std::chrono::steady_clock::duration interval,
3031
std::function<void()> callback) = 0;
3132

33+
// Assign to the specified `destination` a JSON representation of this
34+
// object's configuration. The JSON representation is an object with
35+
// the following properties:
36+
//
37+
// - "type" is the unmangled, qualified name of the most-derived class, e.g.
38+
// "datadog::tracing::ThreadedEventScheduler".
39+
// - "config" is an object containing this object's configuration. "config"
40+
// may be omitted if the derived class has no configuration.
41+
virtual void config_json(nlohmann::json& destination) const = 0;
42+
3243
virtual ~EventScheduler() = default;
3344
};
3445

src/datadog/http_client.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
#include "error.h"
1616
#include "expected.h"
17+
#include "json_fwd.hpp"
1718

1819
namespace datadog {
1920
namespace tracing {
@@ -51,6 +52,16 @@ class HTTPClient {
5152
// `deadline`.
5253
virtual void drain(std::chrono::steady_clock::time_point deadline) = 0;
5354

55+
// Assign to the specified `destination` a JSON representation of this
56+
// object's configuration. The JSON representation is an object with
57+
// the following properties:
58+
//
59+
// - "type" is the unmangled, qualified name of the most-derived class, e.g.
60+
// "datadog::tracing::Curl".
61+
// - "config" is an object containing this object's configuration. "config"
62+
// may be omitted if the derived class has no configuration.
63+
virtual void config_json(nlohmann::json& destination) const = 0;
64+
5465
virtual ~HTTPClient() = default;
5566
};
5667

src/datadog/null_collector.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace tracing {
88
void NullCollector::config_json(nlohmann::json& destination) const {
99
// clang-format off
1010
destination = nlohmann::json::object({
11-
{"type", "NullCollector"},
11+
{"type", "datadog::tracing::NullCollector"},
1212
{"config", nlohmann::json::object({})},
1313
});
1414
// clang-format on

src/datadog/threaded_event_scheduler.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
#include <thread>
44

5+
#include "json.hpp"
6+
57
namespace datadog {
68
namespace tracing {
79

@@ -56,6 +58,11 @@ EventScheduler::Cancel ThreadedEventScheduler::schedule_recurring_event(
5658
};
5759
}
5860

61+
void ThreadedEventScheduler::config_json(nlohmann::json& destination) const {
62+
destination = nlohmann::json::object(
63+
{{"type", "datadog::tracing::ThreadedEventScheduler"}});
64+
}
65+
5966
void ThreadedEventScheduler::run() {
6067
std::unique_lock<std::mutex> lock(mutex_);
6168

src/datadog/threaded_event_scheduler.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,10 @@ class ThreadedEventScheduler : public EventScheduler {
5454
ThreadedEventScheduler();
5555
~ThreadedEventScheduler();
5656

57-
virtual Cancel schedule_recurring_event(
58-
std::chrono::steady_clock::duration interval,
59-
std::function<void()> callback) override;
57+
Cancel schedule_recurring_event(std::chrono::steady_clock::duration interval,
58+
std::function<void()> callback) override;
59+
60+
void config_json(nlohmann::json& destination) const override;
6061
};
6162

6263
} // namespace tracing

test/mocks/event_schedulers.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include <datadog/event_scheduler.h>
44

55
#include <chrono>
6+
#include <datadog/json.hpp>
67
#include <functional>
78
#include <optional>
89

@@ -19,4 +20,8 @@ struct MockEventScheduler : public EventScheduler {
1920
recurrence_interval = interval;
2021
return [this]() { cancelled = true; };
2122
}
23+
24+
void config_json(nlohmann::json& destination) const override {
25+
destination = nlohmann::json::object({{"type", "MockEventScheduler"}});
26+
}
2227
};

0 commit comments

Comments
 (0)