# Copyright 2024 RustFS Team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

[package]
name = "rustfs-obs"
edition.workspace = true
license.workspace = true
repository.workspace = true
rust-version.workspace = true
version.workspace = true
homepage.workspace = true
description = "Observability and monitoring tools for RustFS, providing metrics, logging, and tracing capabilities."
keywords = ["observability", "metrics", "logging", "tracing", "RustFS"]
categories = ["web-programming", "development-tools::profiling", "asynchronous", "api-bindings", "development-tools::debugging"]
documentation = "https://docs.rs/rustfs-obs/latest/rustfs_obs/"

[features]
default = []
hotpath = [
    "hotpath/hotpath",
    "hotpath/tokio",
    "hotpath/futures",
    "hotpath/crossbeam",
    "rustfs-audit/hotpath",
    "rustfs-common/hotpath",
    "rustfs-config/hotpath",
    "rustfs-ecstore/hotpath",
    "rustfs-iam/hotpath",
    "rustfs-io-metrics/hotpath",
    "rustfs-notify/hotpath",
    "rustfs-security-governance/hotpath",
    "rustfs-storage-api/hotpath",
    "rustfs-utils/hotpath",
]
hotpath-alloc = [
    "hotpath",
    "hotpath/hotpath-alloc",
    "rustfs-audit/hotpath-alloc",
    "rustfs-common/hotpath-alloc",
    "rustfs-config/hotpath-alloc",
    "rustfs-ecstore/hotpath-alloc",
    "rustfs-iam/hotpath-alloc",
    "rustfs-io-metrics/hotpath-alloc",
    "rustfs-notify/hotpath-alloc",
    "rustfs-security-governance/hotpath-alloc",
    "rustfs-storage-api/hotpath-alloc",
    "rustfs-utils/hotpath-alloc",
]
hotpath-cpu = [
    "hotpath",
    "hotpath/hotpath-cpu",
    "rustfs-audit/hotpath-cpu",
    "rustfs-common/hotpath-cpu",
    "rustfs-config/hotpath-cpu",
    "rustfs-ecstore/hotpath-cpu",
    "rustfs-iam/hotpath-cpu",
    "rustfs-io-metrics/hotpath-cpu",
    "rustfs-notify/hotpath-cpu",
    "rustfs-security-governance/hotpath-cpu",
    "rustfs-storage-api/hotpath-cpu",
    "rustfs-utils/hotpath-cpu",
]
# Tokio runtime-level telemetry. Requires a `--cfg tokio_unstable` build; the
# build script fails the compile when that flag is missing. Off by default so
# ordinary builds neither pay for nor depend on Tokio's unstable API.
dial9 = ["dep:dial9-tokio-telemetry"]
#
# NOTE: there is deliberately no `dial9-taskdump` feature. dial9 only captures a
# task dump for futures it wrapped itself, i.e. those spawned via
# `dial9_tokio_telemetry::spawn`. RustFS spawns with `tokio::spawn` throughout,
# so enabling `tokio/taskdump` would cost a Linux-only build constraint and
# record nothing. Measured on an identical workload: 0 dumps via `tokio::spawn`,
# 14709 via `dial9::spawn`. Re-adding this feature only makes sense together
# with migrating the paths under investigation to dial9's spawner.
# See rustfs/backlog#1157 (D9-16) and dial9-rs/dial9#477.
#
# NOTE: there is deliberately no `dial9-s3` feature. dial9's `worker-s3` feature
# pulls aws-sdk-s3-transfer-manager 0.1.3 (its latest), which pins
# aws-smithy-http-client onto hyper-rustls 0.24 / rustls-webpki 0.101.7. That
# webpki carries RUSTSEC-2026-0098, -0099 and -0104, and `cargo deny` rejects it.
# Feature unification cannot drop a transitive dependency, so this can only be
# fixed upstream. Tracked in rustfs/backlog#1157 (D9-14).
gpu = ["dep:nvml-wrapper"]
pyroscope = ["dep:pyroscope"]

[[example]]
name = "dial9_smoke"
required-features = ["dial9"]

[lints]
workspace = true

[dependencies]
hotpath.workspace = true
rustfs-audit = { workspace = true }
rustfs-common = { workspace = true }
rustfs-config = { workspace = true, features = ["observability"] }
# NOTE: This dependency on rustfs-ecstore is a known architectural limitation.
# The obs crate imports types from ecstore for metrics collection.
# Breaking this dependency would require defining traits in obs and
# implementing them in ecstore, which is a significant refactoring.
# See docs/architecture/obs-ecstore-dependency-inventory.md and
# https://github.com/rustfs/backlog/issues/735 for discussion.
rustfs-ecstore = { workspace = true }
rustfs-iam = { workspace = true }
rustfs-io-metrics = { workspace = true }
rustfs-notify = { workspace = true }
rustfs-security-governance = { workspace = true }
rustfs-storage-api = { workspace = true }
rustfs-utils = { workspace = true, features = ["ip"] }
rustix = { workspace = true, features = ["fs", "stdio"] }
chrono = { workspace = true, features = ["serde"] }
flate2 = { workspace = true }
glob = { workspace = true }
jiff = { workspace = true, features = ["serde"] }
metrics = { workspace = true }
crossbeam-channel = { workspace = true }
crossbeam-deque = { workspace = true }
crossbeam-utils = { workspace = true }
futures-util = { workspace = true }
num_cpus = { workspace = true }
opentelemetry = { workspace = true }
opentelemetry-appender-tracing = { workspace = true, features = ["experimental_span_attributes", "experimental_metadata_attributes"] }
opentelemetry_sdk = { workspace = true, features = ["rt-tokio"] }
opentelemetry-stdout = { workspace = true }
opentelemetry-otlp = { workspace = true, features = ["gzip-http", "reqwest-rustls"] }
opentelemetry-semantic-conventions = { workspace = true, features = ["semconv_experimental"] }
percent-encoding = { workspace = true }
serde = { workspace = true, features = ["derive"] }
serde_json = { workspace = true, features = ["raw_value"] }
tracing = { workspace = true, features = ["std", "attributes"] }
tracing-appender = { workspace = true }
tracing-error = { workspace = true }
tracing-opentelemetry = { workspace = true }
tracing-subscriber = { workspace = true, features = ["fmt", "env-filter", "tracing-log", "local-time", "json"] }
tokio = { workspace = true, features = ["sync", "rt-multi-thread", "time", "macros"] }
tokio-util = { workspace = true, features = ["io", "compat"] }
url.workspace = true
dial9-tokio-telemetry = { workspace = true, optional = true }
thiserror = { workspace = true }
zstd = { workspace = true, features = ["zstdmt"] }
sysinfo = { workspace = true }
nvml-wrapper = { workspace = true, optional = true }

[target.'cfg(any(target_os = "macos", all(target_os = "linux", target_env = "gnu", target_arch = "x86_64")))'.dependencies]
pyroscope = { workspace = true, optional = true, features = ["backend-pprof-rs"] }

[target.'cfg(unix)'.dependencies]
libc = { workspace = true }


[dev-dependencies]
tempfile = { workspace = true }
temp-env = { workspace = true }
log.workspace = true
metrics-util = { workspace = true, features = ["debugging"] }
