跳转到主要内容

Launcher,OpenTelemetry配置层

项目描述

build status PyPI version Downloads

Launcher,Lightstep为OpenTelemetry提供的发行版 🚀 [已弃用]

2023年8月,Lightstep成为ServiceNow云可观察性。为了简化过渡,所有代码工件将继续使用Lightstep名称。您无需进行任何操作即可继续使用此存储库。

什么是Launcher?

Launcher是一个配置层,它为许多OpenTelemetry用户想要配置的选项选择默认值。它为每种语言提供单个功能,以简化对用户可用选项和组件的发现。Launcher的目的是帮助不熟悉OpenTelemetry的用户快速入门所需的功能并进行仪器化。

入门

pip install opentelemetry-launcher

配置

最小设置

from opentelemetry.launcher import configure_opentelemetry
from opentelemetry import trace

configure_opentelemetry(
    service_name="service-123",
    access_token="my-token",  # optional
)

tracer = trace.get_tracer(__name__)

with tracer.start_as_current_span("foo") as span:
    span.set_attribute("attr1", "valu1")
    with tracer.start_as_current_span("bar"):
        with tracer.start_as_current_span("baz"):
            print("Hello world from OpenTelemetry Python!")

额外的跟踪器选项

configure_opentelemetry(
    service_name="service-123",
    service_version="1.2.3",
    access_token="my-token",
    span_exporter_endpoint="https://ingest.lightstep.com:443",
    log_level=debug,
    span_exporter_insecure=False,
)

与自动仪器化的使用

OpenTelemetry Python包括一个命令,允许用户自动为某些第三方库进行仪器化。以下是如何使用此启动器进行自动仪器化的示例。

首先,创建一个新的虚拟环境

cd ~
mkdir auto_instrumentation
virtualenv auto_instrumentation
source auto_instrumentation/bin/activate
pip install opentelemetry-launcher
pip install requests
pip install flask
opentelemetry-bootstrap -a install

完成此操作后,克隆opentelemetry-python存储库以获取示例代码

git clone git@github.com:open-telemetry/opentelemetry-python.git
cd opentelemetry-python
git checkout v1.1.0

设置环境变量

export OTEL_SERVICE_NAME=auto-instrumentation-testing
export LS_ACCESS_TOKEN=<my-token>

运行服务器

cd docs/examples/auto-instrumentation
opentelemetry-instrument python server_uninstrumented.py

在单独的控制台中运行客户端

cd docs/examples/auto-instrumentation
python client.py testing

这应该会产生可以在Lightstep Explorer中捕获的跨度。

配置选项

配置 环境变量 必需 默认
service_name OTEL_SERVICE_NAME y -
service_version LS_SERVICE_VERSION n None
access_token LS_ACCESS_TOKEN n None
metrics_enabled LS_METRICS_ENABLED n False
span_exporter_endpoint OTEL_EXPORTER_OTLP_TRACES_ENDPOINT n https://ingest.lightstep.com:443
span_exporter_insecure OTEL_EXPORTER_OTLP_TRACES_INSECURE n False
propagators OTEL_PROPAGATORS n b3
resource_attributes OTEL_RESOURCE_ATTRIBUTES n telemetry.sdk.language=python,telemetry.sdk.version=0.12b0
log_level OTEL_LOG_LEVEL n ERROR
metrics_exporter_endpoint OTLP_EXPORTER_METRICS_ENDPOINT n https://ingest.lightstep.com:443
metrics_exporter_temporality_preference OTLP_EXPORTER_METRICS_TEMPORALITY_PREFERENCE n cumulative

配置选项 propagators 接受一个逗号分隔的字符串,该字符串将被解释为一个列表。例如,a,b,c,d 将被解释为 ["a", "b", "c", "d"]。配置选项 resource_attributes 接受一个逗号分隔的 key=value 对字符串,该字符串将被解释为一个字典。例如,a=1,b=2,c=3,d=4 将被解释为 {"a": 1, "b": 2, "c": 3, "d": 4}

关于指标的说明

指标支持目前还是 实验性的

Launcher背后的原则

100% 与 OpenTelemetry 兼容

将Launcher组合在一起的一个关键原则是让OpenTelemetry用户的生活变得更简单,这意味着没有特殊配置是必须的,用户必须安装Launcher才能使用OpenTelemetry。这也意味着任何Launcher用户都可以根据自己的需要配置OpenTelemetry的灵活性。

验证

我们与launcher一起做出的另一个决定是为最终用户提供一层配置验证。这使我们能够更快地向用户提供反馈,使他们能够更快地开始收集遥测数据。

现在就可以在 GoJavaJavascriptPython 中使用它,并告诉我们您的想法!


:heart: @ Lightstep

项目详情


下载文件

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

源分布

opentelemetry-launcher-1.16.0.tar.gz (18.2 kB 查看哈希值)

上传时间

构建分布

opentelemetry_launcher-1.16.0-py3-none-any.whl (16.0 kB 查看哈希值)

上传于 Python 3

由...

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