[package] name = "common-telemetry" version = "0.1.1" edition = "2024" description = "Microservice infrastructure library" publish = ["kellnr"] [features] # 默认开启所有功能 default = ["full"] full = [ "error", "telemetry", "with-sqlx", "with-redis", "with-anyhow", "with-validator", ] # --- Error 模块依赖 --- # 开启 error feature 将引入 thiserror, axum, serde error = ["dep:thiserror", "dep:axum", "dep:serde", "dep:serde_json"] # --- Telemetry 模块依赖 --- # 开启 telemetry feature 将引入 tracing 全家桶 telemetry = ["dep:tracing", "dep:tracing-subscriber", "dep:tracing-appender"] # === 第三方库集成特性 (Feature Flags) === # 这里的 dep:xxx 对应下方 dependencies 里的 optional = true with-sqlx = ["dep:sqlx"] with-redis = ["dep:redis"] with-anyhow = ["dep:anyhow"] with-validator = ["dep:validator"] [dependencies] # Error 相关 thiserror = { version = "2.0.18", optional = true } axum = { version = "0.8.8", optional = true } serde = { version = "1.0", features = ["derive"], optional = true } serde_json = { version = "1.0", optional = true } sqlx = { version = "0.8.6", optional = true } redis = { version = "1.0.2", optional = true } anyhow = { version = "1.0", optional = true } validator = { version = "0.20.0", optional = true } # Telemetry 相关 tracing = { version = "0.1", optional = true } tracing-subscriber = { version = "0.3", features = [ "env-filter", "json", ], optional = true } tracing-appender = { version = "0.2", optional = true } # --- 新增测试依赖 --- [dev-dependencies] tokio = { version = "1", features = ["full"] } tower = { version = "0.5.3", features = ["util"] } # 用于模拟 Web 请求 http = "1.0" http-body-util = "0.1" # 用于读取 Body tempfile = "3.8" # 用于创建临时日志目录