BDD项目日志和追踪SDK
Project description
bdd-trace
一个方便 BDD 项目集成 OpenTelemetry 的 Python 库,提供简化的追踪初始化和配置功能。
功能特性
- 简化 OpenTelemetry 集成配置
- 支持开发和生产环境配置
- 提供统一的追踪初始化接口
- 支持 OTLP 导出器配置
- 自动处理追踪器设置
安装
推荐使用 uv 管理依赖:
uv add bdd-trace
uv sync
# 或者用 pip
pip install bdd-trace
然后安装 OpenTelemetry 的各种 Instrumentation:
# uv
uv run opentelemetry-bootstrap -a requirements | uv add -r -
uv sync
# pip
opentelemetry-bootstrap -a install
快速开始
基本使用
# 在所有导入之前,先导入 bdd_trace 并调用 init_trace 初始化
from bdd_trace import Profile, init_trace
# 预置了 DEV, TEST 和 PROD 三个环境的配置
init_trace(service_name="my-service", profile=Profile.DEV)
# 支持自定义配置
init_trace(
service_name="my-service",
# 自定义 OTLP 端点
exporter_otlp_endpoint="http://localhost:4317",
# 其他设置可运行 opentelemetry-instrument --help 查看
fastapi_exclude_urls="/healthCheck",
)
# 设置 profile=NO_TRACE 可以禁用自动追踪
init_trace(service_name="my-service", profile=Profile.NO_TRACE)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
bdd_trace-0.5.2.tar.gz
(3.7 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file bdd_trace-0.5.2.tar.gz.
File metadata
- Download URL: bdd_trace-0.5.2.tar.gz
- Upload date:
- Size: 3.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1aff4586cf6f166932cac07119d7ce3ee0786744aee3544d2ea35e5a2fd2a28c
|
|
| MD5 |
e0771c62fd1a231b8cd4c2dafec63bc7
|
|
| BLAKE2b-256 |
5b10a3f9d1d76d0addc85885a1c499244c52c01dec793e656f4e339c090c4615
|
File details
Details for the file bdd_trace-0.5.2-py3-none-any.whl.
File metadata
- Download URL: bdd_trace-0.5.2-py3-none-any.whl
- Upload date:
- Size: 4.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
afa5eaa07f04fdd3dba1ed193ad75a1e58d54b24b30aa4b3ce6ce6ac1ff26d32
|
|
| MD5 |
7b46ff1a89536035b3513a7a80d4a902
|
|
| BLAKE2b-256 |
32b978325e889fbb36b1302bf8dd685c232169220776b06147249df045d62fb6
|