pub struct SamplerConfig { /* private fields */ }Expand description
Settings supplied by one APM_SAMPLING configuration.
The payload and each settings value in it must be a JSON object or null, as the Datadog Agent’s JSON decoder
requires; serde’s derived visitors would also accept an array of field values, such as [].
Call resolve to combine the configuration with local settings for one environment.
{
"all_envs": { "priority_sampler_target_TPS": 10, "errors_sampler_target_TPS": 5, "rare_sampler_enabled": true },
"by_env": [{ "env": "prod", "config": { "rare_sampler_enabled": false } }]
}Missing and null fields fall back through all_envs to local settings; 0 and false are explicit values. A
payload that sets nothing, such as {} or null, is still an assigned configuration
(RemoteSampling::Remote) and resolves entirely to local settings, not to previous remote values. This differs
from an empty assignment, which leaves the last accepted configuration in place.
The Datadog Agent sends the *_TPS field names. Lowercase *_tps names also work;
unknown fields are ignored.
Implementations§
Source§impl SamplerConfig
impl SamplerConfig
Sourcepub fn resolve(
&self,
env: &str,
static_settings: &SamplerSettings,
) -> SamplerSettings
pub fn resolve( &self, env: &str, static_settings: &SamplerSettings, ) -> SamplerSettings
Combines remote overrides with local sampling settings for the Agent’s environment.
The result contains target traces per second for priority and error sampling, plus an on/off switch for rare sampling. Priority sampling honors existing decisions to keep or drop traces and uses its target to compute sampling rates. Error sampling can keep error traces that would otherwise be dropped; rare sampling keeps examples of rarely seen operations.
env identifies the Agent’s deployment environment, such as prod, not an individual trace’s environment.
The caller supplies the Agent’s resolved, normalized environment. This method neither derives that environment
nor normalizes names: a remote name of Prod does not match prod.
This method selects the last by_env entry whose name exactly matches env. Earlier matching entries
contribute nothing, even if the selected entry leaves fields unset. For each setting independently, it uses:
- The value in the selected entry’s
config, if set. - Otherwise, the value in
all_envs, the remote settings shared by all environments. - Otherwise, the value in
static_settings, the original local settings, not previous remote values.
Missing or null fields are unset; 0 and false are explicit overrides. If no entry matches env, each
setting falls back to all_envs, then static_settings. Numeric targets pass through without validation or
clamping.
For example, suppose the selected prod entry sets only the priority target to 20 and all_envs sets only
the error target to 5. The result uses 20 for priority sampling, 5 for error sampling, and the local setting
for rare sampling.
Trait Implementations§
Source§impl Clone for SamplerConfig
impl Clone for SamplerConfig
Source§fn clone(&self) -> SamplerConfig
fn clone(&self) -> SamplerConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for SamplerConfig
impl Debug for SamplerConfig
Source§impl Default for SamplerConfig
impl Default for SamplerConfig
Source§fn default() -> SamplerConfig
fn default() -> SamplerConfig
Source§impl<'de> Deserialize<'de> for SamplerConfig
impl<'de> Deserialize<'de> for SamplerConfig
Source§fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
Source§impl PartialEq for SamplerConfig
impl PartialEq for SamplerConfig
impl StructuralPartialEq for SamplerConfig
Auto Trait Implementations§
impl Freeze for SamplerConfig
impl RefUnwindSafe for SamplerConfig
impl Send for SamplerConfig
impl Sync for SamplerConfig
impl Unpin for SamplerConfig
impl UnsafeUnpin for SamplerConfig
impl UnwindSafe for SamplerConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::RequestSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> Track for T
impl<T> Track for T
Source§fn track_resources(self, token: ResourceGroupToken) -> Tracked<Self>
fn track_resources(self, token: ResourceGroupToken) -> Tracked<Self>
Tracked wrapper. Read moreSource§fn in_current_resource_group(self) -> Tracked<Self>
fn in_current_resource_group(self) -> Tracked<Self>
Tracked wrapper. Read more