refactor(build): feature-gate OTLP and AppSec subsystems (default-on)#1280
Closed
duncanista wants to merge 2 commits into
Closed
Conversation
Put the otlp and appsec subsystems behind Cargo features that are ON by default, so the shipped binary is unchanged, but can be turned off to drop their heavy, exclusive dependencies: - otlp gates: opentelemetry-proto, opentelemetry-semantic-conventions, tonic, tonic-types (all otlp-only; prost stays since it is shared with proxy/interceptor, traces/trace_processor and datadog-protos). - appsec gates: libddwaf (and transitively libddwaf-sys + its C build toolchain and aws-lc crypto). lib.rs cfg-gates 'pub mod otlp' / 'pub mod appsec'. When appsec is off, an uninhabited AppSecProcessorStub stands in for the processor type so the Option<Arc<Mutex<..>>> fields, the proxy state tuple, and all 'appsec: None' call sites keep the same shape; only the code paths that actually call into the WAF are cfg-gated. start_otlp_agent gets a no-op fallback returning None. fips implies appsec (FIPS-mode WAF requires libddwaf compiled in). Both the default build and a build with everything in 'default' except otlp/appsec are clippy-clean (pedantic + unwrap_used denied).
Contributor
|
fips builds use --no-default-features --features=fips, which omitted otlp and would drop the OTLP subsystem from shipped FIPS layers. Add otlp to the fips feature list alongside appsec.
Contributor
Author
|
Closing: the extension always ships as a single binary with all subsystems compiled in, and OTLP/AppSec are enabled at runtime via env vars — so compile-time feature-gating provides no value for the shipped product. The disabled subsystems also do no eager work at init, so there's no cold-start win either (only a build-time/size effect that we never actually take advantage of given the single-artifact shipping model). Reopen if the shipping model ever changes to slim/per-feature binaries. |
12 tasks
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.
Note
DRAFT — stacked on #1271 (
jordan.gonzalez/cold-start-instrumentation/feature). Review/merge that PR first; this diff is scoped to the build/feature-gating change on top of it.Jira: none yet — add before marking ready.
Overview
Puts the
otlpandappsecsubsystems behind Cargo features that are ON by default, so the shipped binary is byte-for-byte unchanged, but can be turned off to drop their heavy, exclusive dependencies. This is part of the cold-start dependency/binary-size reduction work (Confluence H13).Deps gated
otlpfeature →opentelemetry-proto,opentelemetry-semantic-conventions,tonic,tonic-types(verified otlp-only).appsecfeature →libddwaf(and transitivelylibddwaf-sys+ its C build toolchain —bindgen/clang-sys/cmake/nom/tar/… — plusaws-lc-rs/aws-lc-sys).Deliberately NOT gated
prost— shared: used byproxy/interceptor.rs,traces/trace_processor.rs, anddatadog-protos. Left as a normal dependency (verified by grep before gating).How the gating works
src/lib.rs:#[cfg(feature = "otlp")] pub mod otlp;and#[cfg(feature = "appsec")] pub mod appsec;.appsecis off, an uninhabitedAppSecProcessorStubenum stands in for the processor type, so theOption<Arc<Mutex<…>>>fields (SendingTraceProcessor,TraceAgent), the proxyInterceptorStatetuple, and everyappsec: Noneconstruction site keep the same shape across both builds. Only the code paths that actually call into the WAF (process_span/process_invocation_next/process_invocation_result/ hold-trace) are#[cfg(feature = "appsec")]-gated. The stub is never constructed (theOptionis alwaysNone).start_otlp_agentgets a no-op#[cfg(not(feature = "otlp"))]fallback that returnsNone, so its call site and shutdown wiring are unchanged.fipsnow impliesappsec(FIPS-mode WAF requireslibddwafcompiled in);fipsfeature resolution verified to still pull inlibddwaf.Dependency-graph delta (proxy for binary size — a precise stripped/LTO/cross-target binary measurement was not run, it is expensive): turning off
otlp+appsecdrops 26 crates from the graph (396 → 370), including the native-compiledlibddwaf-sys+aws-lc-sysand thebindgen/clang/cmakebuild chain.Testing
Both builds are clippy-clean (pedantic +
unwrap_useddenied; only the pre-existing acceptedbuf_redux/multipartfuture-incompat note remains):cargo clippy --bin bottlecap --no-deps→ exit 0cargo clippy --all-targets --no-deps(compiles tests) → exit 0defaultEXCEPT otlp/appsec) — verified:libddwaf/libddwaf-sysconfirmed absent from the dependency graph; directopentelemetry-proto/tonic-typesdropped).