跳转到主要内容

OpenTelemetry Baggage Span Processor

项目描述

pypi

The BaggageSpanProcessor reads entries stored in Baggage from the parent context and adds the baggage entries’ keys and values to the span as attributes on span start.

安装

pip install opentelemetry-processor-baggage

Add this span processor to a tracer provider.

Keys and values added to Baggage will appear on subsequent child spans for a trace within this service and be propagated to external services in accordance with any configured propagation formats configured. If the external services also have a Baggage span processor, the keys and values will appear in those child spans as well.

[!WARNING]

Do not put sensitive information in Baggage.

To repeat: a consequence of adding data to Baggage is that the keys and values will appear in all outgoing HTTP headers from the application.

## 使用

Add the span processor when configuring the tracer provider.

配置span处理器以在配置期间复制所有行李条目

from opentelemetry.processor.baggage import BaggageSpanProcessor, ALLOW_ALL_BAGGAGE_KEYS

tracer_provider = TracerProvider()
tracer_provider.add_span_processor(BaggageSpanProcessor(ALLOW_ALL_BAGGAGE_KEYS))

或者,您可以提供自定义的行李键谓词来选择要复制的行李键。

例如,仅复制以my-key开头的行李条目

starts_with_predicate = lambda baggage_key: baggage_key.startswith("my-key")
tracer_provider.add_span_processor(BaggageSpanProcessor(starts_with_predicate))

例如,仅复制匹配正则表达式^key.+的行李条目

regex_predicate = lambda baggage_key: baggage_key.startswith("^key.+")
tracer_provider.add_span_processor(BaggageSpanProcessor(regex_predicate))

参考

项目详情


下载文件

下载适用于您的平台的文件。如果您不确定选择哪一个,请了解更多关于安装包的信息。

源代码分发

opentelemetry_processor_baggage-0.48b0.tar.gz (7.6 kB 查看哈希值)

上传时间 源代码

构建分发

opentelemetry_processor_baggage-0.48b0-py3-none-any.whl (8.9 kB 查看哈希值)

上传时间 Python 3

由以下机构支持

AWS AWS 云计算和安全赞助商 Datadog Datadog 监控 Fastly Fastly CDN Google Google 下载分析 Microsoft Microsoft PSF 赞助商 Pingdom Pingdom 监控 Sentry Sentry 错误记录 StatusPage StatusPage 状态页面