feat(project): init

This commit is contained in:
2026-01-29 14:37:31 +08:00
commit 88868050ba
8 changed files with 627 additions and 0 deletions

43
Cargo.toml Normal file
View File

@@ -0,0 +1,43 @@
[package]
name = "common-telemetry"
version = "0.1.0"
edition = "2024"
description = "Microservice infrastructure library"
publish = ["kellnr"]
[features]
# 默认开启所有功能
default = ["full"]
full = ["error", "telemetry"]
# --- 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"]
[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 }
# 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" # 用于创建临时日志目录