Respect child-scope override for tracing directives#62
Merged
pawelchcki merged 3 commits intomainfrom Apr 22, 2026
Merged
Conversation
Contributor
Author
This was referenced Apr 21, 2026
33fa3c7 to
48fc79d
Compare
e6962bf to
0b3660e
Compare
48fc79d to
92f2ff9
Compare
0b3660e to
8995192
Compare
92f2ff9 to
52d97f8
Compare
8995192 to
311f10b
Compare
52d97f8 to
c499813
Compare
311f10b to
a5ab2ec
Compare
c499813 to
6b73a7b
Compare
a5ab2ec to
02bf4c1
Compare
02bf4c1 to
5929c41
Compare
There was a problem hiding this comment.
Pull request overview
This PR fixes Apache directory-scope configuration merging so child scopes can explicitly override tracing directives (e.g., DatadogTracing Off inside a <Location>), instead of being forced on by an enclosing implicit default.
Changes:
- Switched
Directory::tracing_enabledandDirectory::trust_inbound_spanfrombooltostd::optional<bool>to distinguish “unset/inherit” vs “explicitly set”. - Updated per-directory merge logic to inherit only when the child scope didn’t set a value.
- Updated tracing hook read sites to apply the effective default (
true) via.value_or(true).
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
mod_datadog/src/tracing/hooks.cpp |
Applies default-on behavior at read sites using value_or(true) for the new optional config fields. |
mod_datadog/src/common_conf.h |
Converts the per-directory flags to std::optional<bool> and documents inheritance semantics. |
mod_datadog/src/common_conf.cpp |
Implements tri-state merge so explicit child directives override parent/default settings. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
2cd8705 to
752bcc6
Compare
5929c41 to
2c2809a
Compare
This comment has been minimized.
This comment has been minimized.
a8401e5 to
8aecbac
Compare
tracing_enabled and trust_inbound_span were plain `bool` with a default of `true`, and merge_dir_conf OR'd parent and child together. That silently dropped `DatadogTracing Off` inside a <Location>: the enclosing scope's implicit `true` always won the OR, so tracing stayed on for the child. Switch both Directory fields to std::optional<bool> so the directive handler's explicit write (true/false) is distinguishable from the default (nullopt). Merge now falls back to the parent only when the child never set the directive; read sites apply the default via .value_or(true).
8aecbac to
7851f6f
Compare
1330904 to
3f08c42
Compare
7851f6f to
066310c
Compare
066310c to
130bcf8
Compare
Matches the already-qualified cast on the non-subrequest branch a few lines below. Namespace lookup currently happens to resolve, but would break if another `conf` enters visibility in this TU.
130bcf8 to
f8e8f97
Compare
xlamorlette-datadog
approved these changes
Apr 22, 2026
xlamorlette-datadog
approved these changes
Apr 22, 2026
xlamorlette-datadog
approved these changes
Apr 22, 2026
xlamorlette-datadog
approved these changes
Apr 22, 2026
| ap_get_module_config(main_r->per_dir_config, datadog_module)); | ||
| if (dir_conf == nullptr || !dir_conf->tracing_enabled) return DECLINED; | ||
| if (dir_conf == nullptr || !dir_conf->tracing_enabled.value_or(true)) | ||
| return DECLINED; |
Contributor
There was a problem hiding this comment.
Please add braces when if … return is not on a single line (to avoid potential bug when adding a line before the return).
Same below, line 121.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

tracing_enabledandtrust_inbound_spanwere plainbools defaulting totrue, andmerge_dir_confOR'd parent with child — soDatadogTracing Off(orDatadogTrustInboundSpan Off) inside a<Location>was silently dropped: the enclosing scope's implicittruealways won the OR.Switch both
Directoryfields tostd::optional<bool>so an explicit directive (true/false) is distinguishable from "unset" (nullopt). Merge now falls back to the parent only when the child never set the directive; read sites apply the default via.value_or(true).Follow-up: #65 tracks adding an integration test for
DatadogTracing Offin a child scope (theDatadogTrustInboundSpancase is already covered bytest_trust_inbound_span_directive).