libdd-common 4.0.0

Shared utilities for Datadog libraries including HTTP/HTTPS connectors, container entity detection, tag validation, rate limiting, and Unix/Windows platform helpers
Documentation
# Copyright 2021-Present Datadog, Inc. https://www.datadoghq.com/
# SPDX-License-Identifier: Apache-2.0

[package]
name = "libdd-common"
version = "4.0.0"
description = "Shared utilities for Datadog libraries including HTTP/HTTPS connectors, container entity detection, tag validation, rate limiting, and Unix/Windows platform helpers"
homepage = "https://github.com/DataDog/libdatadog/tree/main/datadog-common"
repository = "https://github.com/DataDog/libdatadog/tree/main/datadog-common"
edition.workspace = true
rust-version.workspace = true
license.workspace = true

[lib]
crate-type = ["lib"]
bench = false

[dependencies]
anyhow = "1.0"
futures = "0.3"
futures-core = { version = "0.3.0", default-features = false }
futures-util = { version = "0.3.0", default-features = false }
hex = "0.4"
httparse = { version = "1.9", optional = true }
http = "1"
mime = { version = "0.3.16", optional = true }
multer = { version = "3.1", optional = true }
bytes = { version = "1.11.1" }
pin-project = "1"
rand = { version = "0.8", optional = true }
regex = "1.5"
# Use hickory-dns instead of the default system DNS resolver to avoid fork safety issues.
# The default resolver can hold locks or other global state that can cause deadlocks
# or corruption when the process forks (e.g., in PHP-FPM or other forking environments).
# Use rustls-no-provider instead of rustls to avoid reqwest forcing aws-lc-rs as the crypto
# backend. We install the ring provider explicitly in connector/mod.rs instead.
reqwest = { version = "0.13.2", features = ["rustls-no-provider", "hickory-dns"], default-features = false, optional = true }
criterion = { version = "0.5.1", optional = true }
# Pinned to <0.8.3: version 0.8.3+ pulls in openssl-probe@0.2 which probes multiple
# certificate directories and parses individual cert files instead of loading a single
# bundle, adding unnecessary I/O overhead in latency-sensitive environments.
rustls-native-certs = { version = ">=0.8.1, <0.8.3", optional = true }
thiserror = "1.0"
tokio-rustls = { version = "0.26", default-features = false, optional = true }
serde = { version = "1.0", features = ["derive"] }
static_assertions = "1.1.0"
const_format = "0.2.34"
# Declare rustls and hyper-rustls without a crypto provider. The provider is
# selected via features: `https` enables ring, `fips` enables aws-lc-rs.
rustls = { version = "0.23.37", default-features = false, optional = true }
hyper-rustls = { version = "0.27.7", default-features = false, features = [
    "native-tokio",
    "http1",
    "tls12",
], optional = true }

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
hyper = { workspace = true }
hyper-util = { workspace = true }
http-body = "1.0"
http-body-util = "0.1"
tower-service = "0.3"
cc = "1.1.31"
pin-project = "1"
libc = "0.2"
tokio = { version = "1.23", features = ["rt", "rt-multi-thread", "macros", "net", "io-util", "fs", "time"] }

[target.'cfg(windows)'.dependencies.windows-sys]
version = "0.52"
features = [
    "Win32_Foundation",
    "Win32_System_Diagnostics_ToolHelp",
    "Win32_System_Performance",
    "Win32_System_Threading",
]

[target.'cfg(unix)'.dependencies]
nix = { version = "0.29", features = ["process"] }

[dev-dependencies]
httparse = "1.9"
indexmap = "2.11"
maplit = "1.0"
mime = "0.3.16"
multer = "3.1"
bytes = "1.11.1"
rand = "0.8"
tempfile = "3.8"
tokio = { version = "1.23", features = ["rt", "macros", "time"] }

[features]
default = ["https"]
# TLS plumbing without a crypto provider. Use `https` or `fips` to select one.
tls-core = ["tokio-rustls", "rustls", "hyper-rustls", "rustls-native-certs"]
# Default HTTPS: ring as crypto provider
https = ["tls-core", "rustls/ring", "hyper-rustls/ring"]
use_webpki_roots = ["hyper-rustls/webpki-roots"]
# Enable this feature to enable stubbing of cgroup
# php directly import this crate and uses functions gated by this feature for their test
cgroup_testing = []
# FIPS mode uses the FIPS-compliant cryptographic provider (Unix only)
fips = ["tls-core", "hyper-rustls/fips"]
# Enable reqwest client builder support with file dump debugging
reqwest = ["dep:reqwest", "test-utils"]
# Enable test utilities for use in other crates
test-utils = ["dep:httparse", "dep:rand", "dep:mime", "dep:multer"]
# Enable benchmark utilities (ReportingAllocator, Criterion allocation measurement)
bench-utils = ["dep:criterion"]

[lints.rust]
# We run coverage checks in our github actions. These checks are run with
# --all-features which is incompatible with our fips feature. The crypto
# provider default needs to be set by the caller in fips mode. For now, we want
# to make sure that the coverage tests use the non-fips version of the crypto
# provider initialization logic, so we added a coverage cfg check on the
# function in src/connector/mod.rs. The coverage config is actually not used in
# normal environments, so we need to let the rust linter know that it is in
# fact a real thing, though one that shows up only in some situations.
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(coverage)'] }