@@ -689,32 +689,8 @@ std::string Telemetry::extended_heartbeat_payload() {
689689 auto configuration_json = nlohmann::json::array ();
690690
691691 for (const auto & [name, config_metadata] : all_configurations_) {
692- auto seq_id = config_seq_ids_[name];
693- auto j = nlohmann::json{{" name" , to_string (config_metadata.name )},
694- {" value" , config_metadata.value },
695- {" seq_id" , seq_id}};
696-
697- switch (config_metadata.origin ) {
698- case ConfigMetadata::Origin::ENVIRONMENT_VARIABLE:
699- j[" origin" ] = " env_var" ;
700- break ;
701- case ConfigMetadata::Origin::CODE:
702- j[" origin" ] = " code" ;
703- break ;
704- case ConfigMetadata::Origin::REMOTE_CONFIG:
705- j[" origin" ] = " remote_config" ;
706- break ;
707- case ConfigMetadata::Origin::DEFAULT:
708- j[" origin" ] = " default" ;
709- break ;
710- }
711-
712- if (config_metadata.error ) {
713- j[" error" ] = {{" code" , config_metadata.error ->code },
714- {" message" , config_metadata.error ->message }};
715- }
716-
717- configuration_json.emplace_back (std::move (j));
692+ configuration_json.emplace_back (
693+ serialize_configuration_field (config_metadata, config_seq_ids_[name]));
718694 }
719695
720696 auto extended_hb_msg = nlohmann::json{
@@ -760,14 +736,8 @@ nlohmann::json Telemetry::generate_telemetry_body(std::string request_type) {
760736 });
761737}
762738
763- nlohmann::json Telemetry::generate_configuration_field (
764- const ConfigMetadata& config_metadata) {
765- // NOTE(@dmehala): `seq_id` should start at 1 so that the go backend can
766- // detect between non set fields.
767- config_seq_ids_[config_metadata.name ] += 1 ;
768- auto seq_id = config_seq_ids_[config_metadata.name ];
769- all_configurations_[config_metadata.name ] = config_metadata;
770-
739+ nlohmann::json Telemetry::serialize_configuration_field (
740+ const ConfigMetadata& config_metadata, std::size_t seq_id) {
771741 auto j = nlohmann::json{{" name" , to_string (config_metadata.name )},
772742 {" value" , config_metadata.value },
773743 {" seq_id" , seq_id}};
@@ -799,6 +769,16 @@ nlohmann::json Telemetry::generate_configuration_field(
799769 return j;
800770}
801771
772+ nlohmann::json Telemetry::generate_configuration_field (
773+ const ConfigMetadata& config_metadata) {
774+ // NOTE(@dmehala): `seq_id` should start at 1 so that the go backend can
775+ // detect between non set fields.
776+ config_seq_ids_[config_metadata.name ] += 1 ;
777+ all_configurations_[config_metadata.name ] = config_metadata;
778+ return serialize_configuration_field (config_metadata,
779+ config_seq_ids_[config_metadata.name ]);
780+ }
781+
802782void Telemetry::capture_configuration_change (
803783 const std::vector<tracing::ConfigMetadata>& new_configuration) {
804784 configuration_snapshot_.insert (configuration_snapshot_.begin (),
0 commit comments