-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support changes for nginx-datadog/waf-rem-cfg #143
Conversation
Re: this commit... It looks like Damien added You then saw this causes problems with the POSIX header glob.h and so you removed Here's an alternative workaround that I like better: Change the This change would affect every file in the repository, but now that the structure of includes is not flat, I think it's The Right Way™. The distinction really is just a matter of style. The advantage that comes to mind for what I propose is that someone interested in using the library programmatically can copy the include style without having to grok the examples. That and it makes clearer that the file included is relative to some build-configured search directory, rather than being that or relative to the current file (and not knowing which is the case). |
fc25f95
to
5d69bf5
Compare
5b50509
to
c1ebd40
Compare
c1ebd40
to
58c595a
Compare
@dgoffredo I'm not sold on this being a good idea, style aside because angled includes privilege include directories over local files (and hence you will have problems building another version of the library if you have another version installed globally), but anyway I've added a commit for it. |
@cataphract don't mind fixing the include issue. This issue is being addressed in #144 EDIT: @cataphract I merged #144, the include issue is fixed. I have DataDog/nginx-datadog#106 pending to support changes introduced in dd-trace-cpp. May I suggest you to rebase your branch? |
ca7299e
to
930f9ea
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #143 +/- ##
==========================================
- Coverage 94.46% 94.45% -0.02%
==========================================
Files 72 72
Lines 3797 3805 +8
==========================================
+ Hits 3587 3594 +7
- Misses 210 211 +1 ☔ View full report in Codecov by Sentry. |
I've rebased this and updated nginx-datadog to match. I didn't use your PR in nginx-datadog, though; removing nlhomann::json is a lot more work than you have there. |
c847275
to
a42b961
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left a few comments. Thank you.
// TODO: should be moved to the listener | ||
if (product == product::Flag::APM_TRACING) { | ||
const auto config_json = nlohmann::json::parse(new_config.content); | ||
new_config.version = config_json.at("revision"); | ||
|
||
const auto& targeted_service = config_json.at("service_target"); | ||
if (targeted_service.at("service").get<StringView>() != | ||
tracer_signature_.default_service || | ||
targeted_service.at("env").get<StringView>() != | ||
tracer_signature_.default_environment) { | ||
new_config.state = Configuration::State::error; | ||
new_config.error_message = "Wrong service targeted"; | ||
goto skip_listeners; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO.
[genuine question] Are you planning to move the code to the listener?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, not really. It's not really trivial because the listener currently has no access to tracer_signature_
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[question] Do you mind if I push a commit to remove that technical debt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure go ahead
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done in d11cd52
src/datadog/tracer.cpp
Outdated
{"span_sampler", span_sampler_->config_json()}, | ||
{"injection_styles", join_propagation_styles(injection_styles_)}, | ||
{"extraction_styles", join_propagation_styles(extraction_styles_)}, | ||
{"injection_styles", to_string_vec(injection_styles_)}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you confirm the change?
Before | After |
---|---|
"tracecontext,datadog" | ["tracecontext", "datadog"] |
If so, thank you—this is indeed an improvement. However, the best approach would be to leverage the JSON library.
The code should look something like:
void to_json(nlohmann::json& j, const PropagationStyle& style) {
j = to_string_view(style);
}
And the usage:
...
{"injection_styles", injection_styles_},
...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that's the change. This also fixes the test TestConfiguration.test_in_http
in nginx. With the changes made in this PR it now looks normal:
{
"collector": {
"config": {
"event_scheduler": {
"type": "datadog::nginx::NgxEventScheduler"
},
"flush_interval_milliseconds": 2000,
"http_client": {
"type": "datadog::tracing::Curl"
},
"remote_configuration_url": "http://bogus:1234/v0.7/config",
"request_timeout_milliseconds": 2000,
"shutdown_timeout_milliseconds": 2000,
"telemetry_url": "http://bogus:1234/telemetry/proxy/api/v2/apmtelemetry",
"traces_url": "http://bogus:1234/v0.4/traces"
},
"type": "datadog::tracing::DatadogAgent"
},
"defaults": {
"environment": "fooment",
"service": "foosvc",
"service_type": "web"
},
"environment_variables": {
"DD_REMOTE_CONFIG_POLL_INTERVAL_SECONDS": "1"
},
"extraction_styles": [
"B3",
"Datadog"
],
"injection_styles": [
"B3",
"Datadog"
],
"report_traces": true,
"runtime_id": "31998223-6dc3-4fd6-b4c2-cd1ded711143",
"span_sampler": {
"rules": []
},
"tags_header_size": 512,
"trace_sampler": {
"max_per_second": 200,
"rules": []
},
"version": "[dd-trace-cpp version v0.2.2]"
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed. Thanks, I appreciate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Before merging, could you update the commit message to be more descriptive? Something like, "fix(remote_config): remove unnecessary restriction on configuration content" would be more appropriate.
id and version are not taken from the config body (which doesn't have to be json, and even less has to have specific fields). See https://github.com/DataDog/dd-trace-java/blob/dddda34e07973024fcf7457692ce1c3f892f2ef2/remote-config/remote-config-core/src/main/java/datadog/remoteconfig/state/ProductState.java#L209-L210
d11cd52
to
1621fdb
Compare
Description
See individual commits
See DataDog/nginx-datadog#71
Motivation
The implemetation originally assumed that
service_target
was included in all configuration files. However,, this assumption is incorrect; for instance, Appsec configuration files does not include this field. This PR removes that unnecessary restriction.