@@ -10,12 +10,16 @@ namespace tracing {
1010
1111TracerTelemetry::TracerTelemetry (bool enabled, const Clock& clock,
1212 const std::shared_ptr<Logger>& logger,
13- const TracerSignature& tracer_signature)
13+ const TracerSignature& tracer_signature,
14+ const std::string& integration_name,
15+ const std::string& integration_version)
1416 : enabled_(enabled),
1517 clock_ (clock),
1618 logger_(logger),
1719 tracer_signature_(tracer_signature),
18- hostname_(get_hostname().value_or(" hostname-unavailable" )) {
20+ hostname_(get_hostname().value_or(" hostname-unavailable" )),
21+ integration_name_(integration_name),
22+ integration_version_(integration_version) {
1923 if (enabled_) {
2024 // Register all the metrics that we're tracking by adding them to the
2125 // metrics_snapshots_ container. This allows for simpler iteration logic
@@ -80,14 +84,40 @@ nlohmann::json TracerTelemetry::generate_telemetry_body(
8084}
8185
8286std::string TracerTelemetry::app_started () {
83- auto telemetry_body = generate_telemetry_body (" app-started" );
84- // TODO: environment variables or finalized config details
85- telemetry_body[" payload" ] = nlohmann::json::object ({
86- {" configuration" , nlohmann::json::array ({})},
87-
87+ // clang-format off
88+ auto app_started_msg = nlohmann::json{
89+ {" request_type" , " app-started" },
90+ {" payload" , nlohmann::json{
91+ {" configuration" , nlohmann::json::array ()}
92+ }}
93+ };
94+
95+ auto batch = generate_telemetry_body (" message-batch" );
96+ batch[" payload" ] = nlohmann::json::array ({
97+ std::move (app_started_msg)
8898 });
89- auto app_started_payload = telemetry_body.dump ();
90- return app_started_payload;
99+ // clang-format on
100+
101+ if (!integration_name_.empty ()) {
102+ // clang-format off
103+ auto integration_msg = nlohmann::json{
104+ {" request_type" , " app-integrations-change" },
105+ {" payload" , nlohmann::json{
106+ {" integrations" , nlohmann::json::array ({
107+ nlohmann::json{
108+ {" name" , integration_name_},
109+ {" version" , integration_version_},
110+ {" enabled" , true }
111+ }
112+ })}
113+ }}
114+ };
115+ // clang-format on
116+
117+ batch[" payload" ].emplace_back (std::move (integration_msg));
118+ }
119+
120+ return batch.dump ();
91121}
92122
93123void TracerTelemetry::capture_metrics () {
0 commit comments