Debian Codegraph @

crt/s2n/bindings/rust/standard/s2n-tls-metrics-subscriber/src/detector.rs

raw symbols SCIP
1 // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2 // SPDX-License-Identifier: Apache-2.0
3
4 //! Pluggable detection of synthetic traffic (scanners, health-checks, internal
5 //! load tests, etc.) so consumers can filter such handshakes out of their
6 //! metrics without baking the detection logic into this crate.
7 //!
8 //! Each detector receives the parsed [`ClientHello`] and returns whether the
9 //! handshake should be counted as synthetic. When a detector returns `true`,
10 //! [`AggregatedMetricsSubscriber`] increments only the `synthetic_traffic_count`
11 //! field on the in-progress record; every other counter (including
12 //! `handshake_success_count`) is left untouched, so each metric can be read directly
13 //! as a real traffic figure.
14 //!
15 //! [`ClientHello`]: s2n_tls::client_hello::ClientHello
16 //! [`AggregatedMetricsSubscriber`]: crate::AggregatedMetricsSubscriber
17
18 use std::fmt::Debug;
19
20 use s2n_tls::client_hello::ClientHello;
21
22 /// Returns `true` for handshakes whose [`ClientHello`] should be counted as
23 /// synthetic traffic.
24 ///
25 /// Implementations are called on the handshake-completion path, so they should
26 /// be cheap. Allocations and locks should be avoided.
27 pub trait SyntheticTrafficDetector: Debug + Send + Sync + 'static {
28 fn is_synthetic(&self, client_hello: &ClientHello) -> bool;
29 }