Skip to main content

Aliyun LlamaIndex Instrumentation

Project description

阿里云LlamaIndex自动检测库

这是Python自动检测库,专为LlamaIndex框架设计。通过此库产生的追踪信息完全兼容OpenTelemetry,可以发送到OpenTelemetry收集器进行查看,例如xtrace。

安装

通过下列命令安装aliyun-instrumentation-llama-index

pip3 install  aliyun-instrumentation-llama-index

兼容性

llama-indexaliyun-instrumentation-llama-index两者间的版本兼容性以下所述:

llama-index版本 aliyun-instrumentation-llama-index版本
>=0.10.0, < 0.10.43 >=1.0.0

快速开始

安装必须的包

首先,安装本示范所需的包:

pip install aliyun-instrumentation-llama-index llama-index opentelemetry-sdk opentelemetry-exporter-otlp

设置追踪

以下Python代码用于设置AliyunLlamaIndexInstrumentor来追踪llama-index,并将追踪信息输出至控制台。

from aliyun.instrumentation.llama_index import AliyunLlamaIndexInstrumentor

from opentelemetry import trace
from opentelemetry.sdk.resources import Resource, SERVICE_NAME, SERVICE_VERSION
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import SimpleSpanProcessor, ConsoleSpanExporter

resource = Resource(
    attributes={
        SERVICE_NAME: 'aliyun_llama_index_test',
        SERVICE_VERSION: '0.0.1',
        # "telemetry.sdk.language": "Python",
    }
)
provider = TracerProvider(resource=resource)
provider.add_span_processor(SimpleSpanProcessor(ConsoleSpanExporter()))  # 在控制台输出Trace
trace.set_tracer_provider(provider)
# aliyun llama-index instrumentor
AliyunLlamaIndexInstrumentor().instrument()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page