Skip to content

Conversation

@dmehala
Copy link
Collaborator

@dmehala dmehala commented Jun 14, 2024

Description

Refactor the Remote Configuration (RC) as a standalone module, enabling its use independently of the tracer. Additionally, ensure that external listeners can register and receive configuration updates when RC is embedded in the tracer.

Motivation

ASM needs a way to receives RC updates for NGINX integration.

Changes:

  • Move APM_TRACING updates handling to the configuration manager.
  • Expose the remote_configuration_listeners field in datadog agent config to allow registration of external listeners.
  • Improve the robustness of config path parsing and ensure an error is reported if parsing fails.
  • Add to_upper utility function.
  • Increase test coverage for RC and the new configuration manager behaviour.

Refactor the Remote Configuration (RC) as a standalone module, enabling
its use independently of the tracer. Additionally, ensure that external
listeners can register and receive configuration updates when RC is
embedded in the tracer.

Changes:
  - Move APM_TRACING updates handling to the configuration manager.
  - Expose the `remote_configuration_listeners` field in datadog agent config
    to allow registration of external listeners.
  - Improve the robustness of config path parsing and ensure an error is reported
    if parsing fails.
  - Add `to_upper` utility function.
  - Increase test coverage for RC and the new configuration manager
    behaviour.
@dmehala dmehala requested a review from a team as a code owner June 14, 2024 08:46
@dmehala dmehala requested review from cataphract and pablomartinezbernardo and removed request for a team June 14, 2024 08:46
@codecov-commenter
Copy link

codecov-commenter commented Jun 14, 2024

Codecov Report

Attention: Patch coverage is 92.47788% with 17 lines in your changes missing coverage. Please review.

Project coverage is 94.52%. Comparing base (f1c90ec) to head (2572cab).
Report is 67 commits behind head on main.

Files with missing lines Patch % Lines
src/datadog/remote_config/remote_config.cpp 95.36% 7 Missing ⚠️
src/datadog/datadog_agent.cpp 44.44% 5 Missing ⚠️
src/datadog/config_manager.cpp 93.93% 2 Missing ⚠️
src/datadog/remote_config/product.h 77.77% 2 Missing ⚠️
src/datadog/config_manager.h 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #130      +/-   ##
==========================================
+ Coverage   94.48%   94.52%   +0.03%     
==========================================
  Files          71       73       +2     
  Lines        3720     3798      +78     
==========================================
+ Hits         3515     3590      +75     
- Misses        205      208       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

switch (product) { DD_LIST_REMOTE_CONFIG_PRODUCTS }
#undef X

std::abort();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this is quite unlikely but abort is extreme as it can't be recovered from, perhaps an exception would be better?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it does happen I don't think an exception can help much. The program is in a state where the continuity and integrity of it is questionable.

Copy link
Contributor

@Anilm3 Anilm3 Jun 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Certainly that applies to the remote config client, but otherwise you can't make the assertion beyond that. It makes more sense to capture said exception and disable the RC client than to crash the whole thing irrevocably.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't agree but I can understand how frightening std::abort can be. I addressed your concern in d547482

}

// Keep track of config path received to know which ones to revert.
std::unordered_set<std::string> visited_config;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not familiar with this json library, but if the string views you're using down below persist after the loop it might be worth changing this as well to use views.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. Thank you.

Copy link
Collaborator Author

@dmehala dmehala Jun 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in a32272c

EDIT: Ah! I remember abseil's string view has no hash implementation. That's why I sticked with a string.

using namespace rc::capability;
return APM_TRACING_SAMPLE_RATE | APM_TRACING_TAGS | APM_TRACING_ENABLED |
APM_TRACING_SAMPLE_RULES;
};
Copy link
Contributor

@Anilm3 Anilm3 Jun 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
};
}

Stray ; is causing the benchmarks to fail to build.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addressed in d547482. Thank you.

@pr-commenter
Copy link

pr-commenter bot commented Jun 20, 2024

Benchmarks

Benchmark execution time: 2024-07-02 12:16:02

Comparing candidate commit 2572cab in PR branch dmehala/remote-config-module with baseline commit f1c90ec in branch main.

Found 0 performance improvements and 0 performance regressions! Performance is the same for 1 metrics, 0 unstable metrics.

@dmehala dmehala force-pushed the dmehala/remote-config-module branch from 1901645 to 2572cab Compare July 2, 2024 12:14
@dmehala dmehala merged commit f3958f3 into main Jul 2, 2024
@dmehala dmehala deleted the dmehala/remote-config-module branch July 2, 2024 12:20
@dmehala dmehala mentioned this pull request Aug 15, 2024
dmehala added a commit that referenced this pull request Sep 11, 2024
Resolve a regression introduced in #130 where the `configuration_change`
payload didn't adhere to the telemetry schema.
dmehala added a commit that referenced this pull request Sep 15, 2024
Resolve a regression introduced in #130 where the `configuration_change`
payload didn't adhere to the telemetry schema.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants