fix(error): perf error

This commit is contained in:
2026-01-29 15:49:46 +08:00
parent 88868050ba
commit c5b32f721c
3 changed files with 206 additions and 45 deletions

View File

@@ -1,6 +1,6 @@
[package]
name = "common-telemetry"
version = "0.1.0"
version = "0.1.1"
edition = "2024"
description = "Microservice infrastructure library"
@@ -9,7 +9,14 @@ publish = ["kellnr"]
[features]
# 默认开启所有功能
default = ["full"]
full = ["error", "telemetry"]
full = [
"error",
"telemetry",
"with-sqlx",
"with-redis",
"with-anyhow",
"with-validator",
]
# --- Error 模块依赖 ---
# 开启 error feature 将引入 thiserror, axum, serde
@@ -19,6 +26,13 @@ error = ["dep:thiserror", "dep:axum", "dep:serde", "dep:serde_json"]
# 开启 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 }
@@ -26,6 +40,11 @@ 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 = [