<p align="center">
<a target="_blank" href="https://arize.com" style="background:none">
<img alt="arize banner" src="https://storage.googleapis.com/arize-assets/arize-logo-white.jpg" width="auto" height="auto"></img>
</a>
<br/>
<br/>
<a href="https://docs.arize.com/">
<img src="https://img.shields.io/static/v1?message=Docs&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAYAAADDPmHLAAAG4ElEQVR4nO2d4XHjNhCFcTf+b3ZgdWCmgmMqOKUC0xXYrsBOBVEqsFRB7ApCVRCygrMriFQBM7h5mNlwKBECARLg7jeDscamSQj7sFgsQfBL27ZK4MtXsT1vRADMEQEwRwTAHBEAc0QAzBEBMEcEwBwRAHNEAMwRATBnjAByFGE+MqVUMcYOY24GVUqpb/h8VErVKAf87QNFcEcbd4WSw+D6803njHscO5sATmGEURGBiCj6yUlv1uX2gv91FsDViArbcA2RUKF8QhAV8RQc0b15DcOt0VaTE1oAfWj3dYdCBfGGsmSM0XX5HsP3nEMAXbqCeCdiOERQPx9og5exGJ0S4zRQN9KrUupfpdQWjZciure/YIj7K0bjqwTyAHdovA805iqCOg2xgnB1nZ97IvaoSCURdIPG/IHGjTH/YAz/A8KdJai7lBQzgbpx/0Hg6DT18UzWMXxSjMkDrElPNEmKfAbl6znwI3IMU/OCa0/1nfckwWaSbvWYYDnEsvCMJDNckhqu7GCMKWYOBXp9yPGd5kvqUAKf6rkAk7M2SY9QDXdEr9wEOr9x96EiejMFnixBNteDISsyNw7hHRqc22evWcP4vt39O85bzZH30AKg4+eo8cQRI4bHAJ7hyYM3CNHrG9RrimSXuZmUkZjN/O6nAPpcwCcJNmipAle2QM/1GU3vITCXhvY91u9geN/jOY27VuTnYL1PCeAcRhwh7/Bl8Ai+IuxPiOCShtfX/sPDtY8w+sZjby86dw6dBeoigD7obd/Ko6fI4BF8DA9HnGdrcU0fLt+n4dfE6H5jpjYcVdu2L23b5lpjHoo+18FDbcszddF1rUee/4C6ZiO+80rHZmjDoIQUQLdRtm3brkcKIUPjjqVPBIUH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+QohCiNrwhdgEYzPv7UxkadvBg0RrekMrNoAozh3vLN4DPhc7S/WL52vkoSO1u4BZC+DOCulC0KJ/gqWaP7C8hlSGgjxyCmDuPsEePT/KuasrrAcyr4H+f6fq01yd7Sz1lD0CZ2hs06PVJufs+lrIiyLwufjfBtXYpjvWnWIoHoJSYe4dIK/t4HX1ULFEACkPCm8e8wXFJvZ6y1EWhJkDcWxw7RINzLc74auGrgg8e4oIm9Sh/CA7LwkvHqaIJ9pLI6Lmy1BigDy2EV8tjdzh+8XB6MGSLKH4INsZXDJ8MGhIBK+Mrpo+GnRIBO+MrZjFAFxoTNBwCvj6u4qvSZJiM3iNX4yvmHoA9Sh4PF0QAzBEBMEcEwBwRAHNEAMwRAXBGKfUfr5hKvglRfO4AAAAASUVORK5CYII=&labelColor=grey&color=blue&logoColor=white&label=%20"/>
</a>
<a target="_blank" href="https://join.slack.com/t/arize-ai/shared_invite/zt-1px8dcmlf-fmThhDFD_V_48oU7ALan4Q">
<img src="https://img.shields.io/static/v1?message=Community&logo=slack&labelColor=grey&color=blue&logoColor=white&label=%20"/>
</a>
<br/>
<a target="_blank" href="https://pypi.org/project/arize-otel/">
<img src="https://img.shields.io/pypi/v/arize-otel">
</a>
<a target="_blank" href="https://pypi.org/project/arize-otel/">
<img src="https://img.shields.io/pypi/status/arize-otel?style=flat&logo=ticktick&logoColor=white"/>
</a>
<a target="_blank" href="https://pypi.org/project/arize-otel/">
<img src="https://img.shields.io/pypi/pyversions/arize-otel?logo=python&logoColor=white">
</a>
<a target="_blank" href="https://github.com/Arize-ai/arize-otel-python/blob/main/LICENSE">
<img src="https://img.shields.io/pypi/l/arize-otel">
</a>
</p>
---
- [Overview](#overview)
- [Installation](#installation)
- [Quickstart](#quickstart)
- [Send traces to Arize](#send-traces-to-arize)
- [Send traces to Custom Endpoint](#send-traces-to-custom-endpoint)
- [Specify exporter type](#specify-exporter-type)
- [Turn off batch processing of spans](#turn-off-batch-processing-of-spans)
- [Debug](#debug)
- [Using Environment Variables](#using-environment-variables)
- [Using OTel Primitives](#using-otel-primitives)
- [Specifying the `endpoint` directly](#specifying-the-endpoint-directly)
- [Configuring resources](#configuring-resources)
- [Using a BatchSpanProcessor](#using-a-batchspanprocessor)
- [Specifying a custom GRPC endpoint](#specifying-a-custom-grpc-endpoint)
- [Questions?](#questions)
- [Copyright, Patent, and License](#copyright-patent-and-license)
## Overview
The `arize-otel` package provides a lightweight wrapper around OpenTelemetry primitives with Arize-aware defaults and options. It is meant to be a very lightweight convenience package to help set up OpenTelemetry for tracing LLM applications and send the traces to [Arize](https://arize.com/).
## Installation
Install `arize-otel` using `pip`
```bash
pip install arize-otel
```
## Quickstart
The `arize.otel` module provides a high-level `register` function to configure OpenTelemetry tracing by returning a `TracerProvider`. The register function can also configure headers and whether or not to process spans one by one or by batch.
The following examples showcase how to use `register` to setup Opentelemetry in order to send traces to a collector. However, this is **NOT** the same as [instrumenting](https://docs.arize.com/phoenix/tracing/concepts-tracing/how-does-tracing-work) your application. For instance, you can use any of our [OpenInference AutoInstrumentators](https://github.com/Arize-ai/openinference). Assuming we use the OpenAI AutoInstrumentation, we need to run `instrument()` _after_ using `register`:
```python
from arize.otel import register
# Setup OTel via our convenience function
tracer_provider = register(
# See details in examples below...
)
# Instrument your application using OpenInference AutoInstrumentators
from openinference.instrumentation.openai import OpenAIInstrumentor
OpenAIInstrumentor().instrument(tracer_provider=tracer_provider)
```
The above code snippet will yield a fully setup and instrumented application. It is worth noting that this is completely **optional**. The usage of this package is for convenience only, you can set up OpenTelemetry and send traces to Arize without installing this or any other package from Arize.
In the following sections we have examples on how to use the `register` function:
### Send traces to Arize
To send traces to Arize you need to authenticate via the Space ID and API Key. You can find them in the Space Settings page in the Arize platform. In addition, you'll need to specify the project name, a unique name to identify your project in the Arize platform.
```python
from arize.otel import register
register(
space_id = "your-arize-space-id",
api_key = "your-arize-api-key",
project_name = "your-model-id",
)
```
If you are located in the European Union, you'll need to specify the corresponding `Endpoint` (the default endpoint is `Endpoint.ARIZE`):
```python
from arize.otel import register, Endpoint
register(
endpoint=Endpoint.ARIZE_EUROPE,
space_id = "your-arize-space-id",
api_key = "your-arize-api-key",
project_name = "your-model-id",
)
```
If you would like to configure your tracing using environment variables instead of passing arguments, read [Using Environment Variables](#using-environment-variables).
### Send traces to Custom Endpoint
Sending traces to a collector on a custom endpoint is simple, you just need to provide the endpoint as a string. In addition, it is worth noting that the default is to use a `GRPCSpanExporter`. If you'd like to use a `HTTPSpanExporter` instead, specify the transport as shown below:
```python
from arize.otel import register
register(
endpoint = "https://my-custom-endpoint"
# any other options...
)
```
### Specify exporter type
If you're using endpoints from the `Endpoint` enum, you do not need to do this, since we know what exporter to use. However, if you're using a custom endpoint, it is worth noting that the default is to use a `GRPCSpanExporter`. If you'd like to use a `HTTPSpanExporter` instead, specify the transport as shown below:
```python
from arize.otel import register, Transport
register(
endpoint = "https://my-custom-endpoint"
transport = Transport.HTTP,
# any other options...
)
```
### Turn off batch processing of spans
We default to using [BatchSpanProcessor](https://opentelemetry.io/docs/languages/js/instrumentation/#picking-the-right-span-processor) from OpenTelemetry because it is non-blocking in case telemetry goes down. In contrast, "SimpleSpanProcessor processes spans as they are created." This can be helpful in development. You can use `SimpleSpanProcessor` with the option `use_batch_processor=False`.
```python
from arize.otel import register
register(
# other options...
batch=False
)
```
### Debug
As you're setting up your tracing, it is helpful to print to console the spans created. You can achieve this by setting `log_to_console=True`.
```python
from arize.otel import register
register(
# other options...
log_to_console=True
)
```
## Using Environment Variables
The register function will read from environment variables if the arguments are not passed:
```python
from arize.otel import register
register(
space_id = ... # Will be read from ARIZE_SPACE_ID env var
api_key = ... # Will be read from ARIZE_API_KEY env var
project_name = ... # Will be read from ARIZE_PROJECT_NAME env var
endpoint = ... # Will be read from ARIZE_COLLECTOR_ENDPOINT env var, defaults to Endpoint.Arize
)
```
In the event of conflict, if an environment variable is set but a different argument is passed, the argument passed will take precedence and the environment variable will be ignored.
## Using OTel Primitives
For more granular tracing configuration, these wrappers can be used as drop-in replacements for
OTel primitives:
```python
from opentelemetry import trace as trace_api
from arize.otel import HTTPSpanExporter, TracerProvider, SimpleSpanProcessor
tracer_provider = TracerProvider()
span_exporter = HTTPSpanExporter(endpoint=...)
span_processor = SimpleSpanProcessor(span_exporter=span_exporter)
tracer_provider.add_span_processor(span_processor)
trace_api.set_tracer_provider(tracer_provider)
```
Wrappers have Arize-aware defaults to greatly simplify the OTel configuration process. A special
`endpoint` keyword argument can be passed to either a `TracerProvider`, `SimpleSpanProcessor` or
`BatchSpanProcessor` in order to automatically infer which `SpanExporter` to use to simplify setup.
#### Specifying the `endpoint` directly
```python
from opentelemetry import trace as trace_api
from arize.otel import TracerProvider
tracer_provider = TracerProvider(endpoint="https://your-desired-endpoint.com")
trace_api.set_tracer_provider(tracer_provider)
```
### Configuring resources
```python
# export ARIZE_COLLECTOR_ENDPOINT=https://your-desired-endpoint.com
from opentelemetry import trace as trace_api
from arize.otel import Resource, PROJECT_NAME, TracerProvider
tracer_provider = TracerProvider(resource=Resource({PROJECT_NAME: "my-project"}))
trace_api.set_tracer_provider(tracer_provider)
```
### Using a BatchSpanProcessor
```python
# export ARIZE_COLLECTOR_ENDPOINT=https://your-desired-endpoint.com
from opentelemetry import trace as trace_api
from arize.otel import TracerProvider, BatchSpanProcessor
tracer_provider = TracerProvider()
batch_processor = BatchSpanProcessor()
tracer_provider.add_span_processor(batch_processor)
```
### Specifying a custom GRPC endpoint
```python
from opentelemetry import trace as trace_api
from arize.otel import TracerProvider, BatchSpanProcessor, GRPCSpanExporter
tracer_provider = TracerProvider()
batch_processor = BatchSpanProcessor(
span_exporter=GRPCSpanExporter(endpoint="https://your-desired-endpoint.com")
)
tracer_provider.add_span_processor(batch_processor)
```
## Questions?
Find us in our [Slack Community](https://join.slack.com/t/arize-ai/shared_invite/zt-1px8dcmlf-fmThhDFD_V_48oU7ALan4Q) or email support@arize.com
## Copyright, Patent, and License
Copyright 2024 Arize AI, Inc. All Rights Reserved.
This software is licensed under the terms of the 3-Clause BSD License. See [LICENSE](https://github.com/Arize-ai/arize-otel-python/blob/main/LICENSE).
Raw data
{
"_id": null,
"home_page": null,
"name": "arize-otel",
"maintainer": null,
"docs_url": null,
"requires_python": "<3.13,>=3.8",
"maintainer_email": "Arize AI <support@arize.com>",
"keywords": "Explainability, Monitoring, Observability, Tracing",
"author": null,
"author_email": "Arize AI <support@arize.com>",
"download_url": "https://files.pythonhosted.org/packages/aa/1f/737e504e3b0fd41a56e7cdf03436a249ac7ae9db9c279626855f7ce54868/arize_otel-0.7.1.tar.gz",
"platform": null,
"description": "<p align=\"center\">\n <a target=\"_blank\" href=\"https://arize.com\" style=\"background:none\">\n <img alt=\"arize banner\" src=\"https://storage.googleapis.com/arize-assets/arize-logo-white.jpg\" width=\"auto\" height=\"auto\"></img>\n </a>\n <br/>\n <br/>\n <a href=\"https://docs.arize.com/\">\n <img src=\"https://img.shields.io/static/v1?message=Docs&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAYAAADDPmHLAAAG4ElEQVR4nO2d4XHjNhCFcTf+b3ZgdWCmgmMqOKUC0xXYrsBOBVEqsFRB7ApCVRCygrMriFQBM7h5mNlwKBECARLg7jeDscamSQj7sFgsQfBL27ZK4MtXsT1vRADMEQEwRwTAHBEAc0QAzBEBMEcEwBwRAHNEAMwRATBnjAByFGE+MqVUMcYOY24GVUqpb/h8VErVKAf87QNFcEcbd4WSw+D6803njHscO5sATmGEURGBiCj6yUlv1uX2gv91FsDViArbcA2RUKF8QhAV8RQc0b15DcOt0VaTE1oAfWj3dYdCBfGGsmSM0XX5HsP3nEMAXbqCeCdiOERQPx9og5exGJ0S4zRQN9KrUupfpdQWjZciure/YIj7K0bjqwTyAHdovA805iqCOg2xgnB1nZ97IvaoSCURdIPG/IHGjTH/YAz/A8KdJai7lBQzgbpx/0Hg6DT18UzWMXxSjMkDrElPNEmKfAbl6znwI3IMU/OCa0/1nfckwWaSbvWYYDnEsvCMJDNckhqu7GCMKWYOBXp9yPG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miACYIwJgjgiAOSIA5ogAmCMCYI4IgDkiAOaIAJgjAmCOCIA5IgDmiACYIwJgjgiAOSIA5ogAmCMCYI4IgDkiAOaIAJgjAmDOVYBXvwvxQV8NWJOd0esvJ94babZaz7B5ovldxnlDpYhp0JFr/KTlLKcEMMQKpcDPXIQxGXsYmhZnXAXQh/EWBQrr3bc80mATyyrEvs4+BdBHgbdxFOIhrDkSg1/6Iu2LCS0AyoqI4ftUF00EY/Q3h1fRj2JKAVCMGErmnsH1lfnemEsAlByvgl0z2qx5B8OPCuB8EIMADBlEEOV79j1whNE3c/X2PmISAGUNr7CEmUSUhjfEKgBDAY+QohCiNrwhdgEYzPv7UxkadvBg0RrekMrNoAozh3vLN4DPhc7S/WL52vkoSO1u4BZC+DOCulC0KJ/gqWaP7C8hlSGgjxyCmDuPsEePT/KuasrrAcyr4H+f6fq01yd7Sz1lD0CZ2hs06PVJufs+lrIiyLwufjfBtXYpjvWnWIoHoJSYe4dIK/t4HX1ULFEACkPCm8e8wXFJvZ6y1EWhJkDcWxw7RINzLc74auGrgg8e4oIm9Sh/CA7LwkvHqaIJ9pLI6Lmy1BigDy2EV8tjdzh+8XB6MGSLKH4INsZXDJ8MGhIBK+Mrpo+GnRIBO+MrZjFAFxoTNBwCvj6u4qvSZJiM3iNX4yvmHoA9Sh4PF0QAzBEBMEcEwBwRAHNEAMwRAXBGKfUfr5hKvglRfO4AAAAASUVORK5CYII=&labelColor=grey&color=blue&logoColor=white&label=%20\"/>\n </a>\n <a target=\"_blank\" href=\"https://join.slack.com/t/arize-ai/shared_invite/zt-1px8dcmlf-fmThhDFD_V_48oU7ALan4Q\">\n <img src=\"https://img.shields.io/static/v1?message=Community&logo=slack&labelColor=grey&color=blue&logoColor=white&label=%20\"/>\n </a>\n <br/>\n <a target=\"_blank\" href=\"https://pypi.org/project/arize-otel/\">\n <img src=\"https://img.shields.io/pypi/v/arize-otel\">\n </a>\n <a target=\"_blank\" href=\"https://pypi.org/project/arize-otel/\">\n <img src=\"https://img.shields.io/pypi/status/arize-otel?style=flat&logo=ticktick&logoColor=white\"/>\n </a>\n <a target=\"_blank\" href=\"https://pypi.org/project/arize-otel/\">\n <img src=\"https://img.shields.io/pypi/pyversions/arize-otel?logo=python&logoColor=white\">\n </a>\n <a target=\"_blank\" href=\"https://github.com/Arize-ai/arize-otel-python/blob/main/LICENSE\">\n <img src=\"https://img.shields.io/pypi/l/arize-otel\">\n </a>\n\n</p>\n\n---\n\n- [Overview](#overview)\n- [Installation](#installation)\n- [Quickstart](#quickstart)\n - [Send traces to Arize](#send-traces-to-arize)\n - [Send traces to Custom Endpoint](#send-traces-to-custom-endpoint)\n - [Specify exporter type](#specify-exporter-type)\n - [Turn off batch processing of spans](#turn-off-batch-processing-of-spans)\n - [Debug](#debug)\n- [Using Environment Variables](#using-environment-variables)\n- [Using OTel Primitives](#using-otel-primitives)\n - [Specifying the `endpoint` directly](#specifying-the-endpoint-directly)\n - [Configuring resources](#configuring-resources)\n - [Using a BatchSpanProcessor](#using-a-batchspanprocessor)\n - [Specifying a custom GRPC endpoint](#specifying-a-custom-grpc-endpoint)\n- [Questions?](#questions)\n- [Copyright, Patent, and License](#copyright-patent-and-license)\n\n## Overview\n\nThe `arize-otel` package provides a lightweight wrapper around OpenTelemetry primitives with Arize-aware defaults and options. It is meant to be a very lightweight convenience package to help set up OpenTelemetry for tracing LLM applications and send the traces to [Arize](https://arize.com/).\n\n## Installation\n\nInstall `arize-otel` using `pip`\n\n```bash\npip install arize-otel\n```\n\n## Quickstart\n\nThe `arize.otel` module provides a high-level `register` function to configure OpenTelemetry tracing by returning a `TracerProvider`. The register function can also configure headers and whether or not to process spans one by one or by batch.\n\nThe following examples showcase how to use `register` to setup Opentelemetry in order to send traces to a collector. However, this is **NOT** the same as [instrumenting](https://docs.arize.com/phoenix/tracing/concepts-tracing/how-does-tracing-work) your application. For instance, you can use any of our [OpenInference AutoInstrumentators](https://github.com/Arize-ai/openinference). Assuming we use the OpenAI AutoInstrumentation, we need to run `instrument()` _after_ using `register`:\n\n```python\nfrom arize.otel import register\n# Setup OTel via our convenience function\ntracer_provider = register(\n # See details in examples below...\n)\n\n# Instrument your application using OpenInference AutoInstrumentators\nfrom openinference.instrumentation.openai import OpenAIInstrumentor\nOpenAIInstrumentor().instrument(tracer_provider=tracer_provider)\n\n```\n\nThe above code snippet will yield a fully setup and instrumented application. It is worth noting that this is completely **optional**. The usage of this package is for convenience only, you can set up OpenTelemetry and send traces to Arize without installing this or any other package from Arize.\n\nIn the following sections we have examples on how to use the `register` function:\n\n### Send traces to Arize\n\nTo send traces to Arize you need to authenticate via the Space ID and API Key. You can find them in the Space Settings page in the Arize platform. In addition, you'll need to specify the project name, a unique name to identify your project in the Arize platform.\n\n```python\nfrom arize.otel import register\nregister(\n space_id = \"your-arize-space-id\",\n api_key = \"your-arize-api-key\",\n project_name = \"your-model-id\",\n)\n```\n\nIf you are located in the European Union, you'll need to specify the corresponding `Endpoint` (the default endpoint is `Endpoint.ARIZE`):\n\n```python\nfrom arize.otel import register, Endpoint\nregister(\n endpoint=Endpoint.ARIZE_EUROPE,\n space_id = \"your-arize-space-id\",\n api_key = \"your-arize-api-key\",\n project_name = \"your-model-id\",\n)\n```\n\nIf you would like to configure your tracing using environment variables instead of passing arguments, read [Using Environment Variables](#using-environment-variables).\n\n### Send traces to Custom Endpoint\n\nSending traces to a collector on a custom endpoint is simple, you just need to provide the endpoint as a string. In addition, it is worth noting that the default is to use a `GRPCSpanExporter`. If you'd like to use a `HTTPSpanExporter` instead, specify the transport as shown below:\n\n```python\nfrom arize.otel import register\nregister(\n endpoint = \"https://my-custom-endpoint\"\n # any other options...\n)\n```\n\n### Specify exporter type\n\nIf you're using endpoints from the `Endpoint` enum, you do not need to do this, since we know what exporter to use. However, if you're using a custom endpoint, it is worth noting that the default is to use a `GRPCSpanExporter`. If you'd like to use a `HTTPSpanExporter` instead, specify the transport as shown below:\n\n```python\nfrom arize.otel import register, Transport\nregister(\n endpoint = \"https://my-custom-endpoint\"\n transport = Transport.HTTP,\n # any other options...\n)\n```\n\n### Turn off batch processing of spans\n\nWe default to using [BatchSpanProcessor](https://opentelemetry.io/docs/languages/js/instrumentation/#picking-the-right-span-processor) from OpenTelemetry because it is non-blocking in case telemetry goes down. In contrast, \"SimpleSpanProcessor processes spans as they are created.\" This can be helpful in development. You can use `SimpleSpanProcessor` with the option `use_batch_processor=False`.\n\n```python\nfrom arize.otel import register\nregister(\n # other options...\n batch=False\n)\n```\n\n### Debug\n\nAs you're setting up your tracing, it is helpful to print to console the spans created. You can achieve this by setting `log_to_console=True`.\n\n```python\nfrom arize.otel import register\nregister(\n # other options...\n log_to_console=True\n)\n```\n\n## Using Environment Variables\n\nThe register function will read from environment variables if the arguments are not passed:\n\n```python\nfrom arize.otel import register\nregister(\n space_id = ... # Will be read from ARIZE_SPACE_ID env var\n api_key = ... # Will be read from ARIZE_API_KEY env var\n project_name = ... # Will be read from ARIZE_PROJECT_NAME env var\n endpoint = ... # Will be read from ARIZE_COLLECTOR_ENDPOINT env var, defaults to Endpoint.Arize\n)\n```\n\nIn the event of conflict, if an environment variable is set but a different argument is passed, the argument passed will take precedence and the environment variable will be ignored.\n\n## Using OTel Primitives\n\nFor more granular tracing configuration, these wrappers can be used as drop-in replacements for\nOTel primitives:\n\n```python\nfrom opentelemetry import trace as trace_api\nfrom arize.otel import HTTPSpanExporter, TracerProvider, SimpleSpanProcessor\n\ntracer_provider = TracerProvider()\nspan_exporter = HTTPSpanExporter(endpoint=...)\nspan_processor = SimpleSpanProcessor(span_exporter=span_exporter)\ntracer_provider.add_span_processor(span_processor)\ntrace_api.set_tracer_provider(tracer_provider)\n```\n\nWrappers have Arize-aware defaults to greatly simplify the OTel configuration process. A special\n`endpoint` keyword argument can be passed to either a `TracerProvider`, `SimpleSpanProcessor` or\n`BatchSpanProcessor` in order to automatically infer which `SpanExporter` to use to simplify setup.\n\n#### Specifying the `endpoint` directly\n\n```python\nfrom opentelemetry import trace as trace_api\nfrom arize.otel import TracerProvider\n\ntracer_provider = TracerProvider(endpoint=\"https://your-desired-endpoint.com\")\ntrace_api.set_tracer_provider(tracer_provider)\n```\n\n### Configuring resources\n\n```python\n# export ARIZE_COLLECTOR_ENDPOINT=https://your-desired-endpoint.com\n\nfrom opentelemetry import trace as trace_api\nfrom arize.otel import Resource, PROJECT_NAME, TracerProvider\n\ntracer_provider = TracerProvider(resource=Resource({PROJECT_NAME: \"my-project\"}))\ntrace_api.set_tracer_provider(tracer_provider)\n```\n\n### Using a BatchSpanProcessor\n\n```python\n# export ARIZE_COLLECTOR_ENDPOINT=https://your-desired-endpoint.com\n\nfrom opentelemetry import trace as trace_api\nfrom arize.otel import TracerProvider, BatchSpanProcessor\n\ntracer_provider = TracerProvider()\nbatch_processor = BatchSpanProcessor()\ntracer_provider.add_span_processor(batch_processor)\n```\n\n### Specifying a custom GRPC endpoint\n\n```python\nfrom opentelemetry import trace as trace_api\nfrom arize.otel import TracerProvider, BatchSpanProcessor, GRPCSpanExporter\n\ntracer_provider = TracerProvider()\nbatch_processor = BatchSpanProcessor(\n span_exporter=GRPCSpanExporter(endpoint=\"https://your-desired-endpoint.com\")\n)\ntracer_provider.add_span_processor(batch_processor)\n```\n\n## Questions?\n\nFind us in our [Slack Community](https://join.slack.com/t/arize-ai/shared_invite/zt-1px8dcmlf-fmThhDFD_V_48oU7ALan4Q) or email support@arize.com\n\n## Copyright, Patent, and License\n\nCopyright 2024 Arize AI, Inc. All Rights Reserved.\n\nThis software is licensed under the terms of the 3-Clause BSD License. See [LICENSE](https://github.com/Arize-ai/arize-otel-python/blob/main/LICENSE).\n",
"bugtrack_url": null,
"license": "BSD",
"summary": "Helper package for OTEL setup to send traces to Arize & Phoenix",
"version": "0.7.1",
"project_urls": {
"Changelog": "https://github.com/Arize-ai/arize-otel-python/blob/main/CHANGELOG.md",
"Documentation": "https://docs.arize.com/arize/large-language-models/tracing",
"Issues": "https://github.com/Arize-ai/arize-otel-python/issues",
"Source": "https://github.com/Arize-ai/arize-otel-python"
},
"split_keywords": [
"explainability",
" monitoring",
" observability",
" tracing"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "06c489a2115e5e91ad8ed12258bec7f8a0ff9b60bb9e11f99ae4d13b1f6a00a0",
"md5": "e5c99544b0b2c2e8724d938d535e04fb",
"sha256": "e76f9d4443f76cc5ed21b365b5cd5fd131051a9c53c5c466f71b5211436c42fb"
},
"downloads": -1,
"filename": "arize_otel-0.7.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "e5c99544b0b2c2e8724d938d535e04fb",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<3.13,>=3.8",
"size": 13033,
"upload_time": "2024-12-13T18:38:00",
"upload_time_iso_8601": "2024-12-13T18:38:00.460621Z",
"url": "https://files.pythonhosted.org/packages/06/c4/89a2115e5e91ad8ed12258bec7f8a0ff9b60bb9e11f99ae4d13b1f6a00a0/arize_otel-0.7.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "aa1f737e504e3b0fd41a56e7cdf03436a249ac7ae9db9c279626855f7ce54868",
"md5": "8b1d3143b1e2d563f245ee25f7295de8",
"sha256": "060ed595f95224b1e1991a6af40371efd355972d7eefece303960b742c268d14"
},
"downloads": -1,
"filename": "arize_otel-0.7.1.tar.gz",
"has_sig": false,
"md5_digest": "8b1d3143b1e2d563f245ee25f7295de8",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<3.13,>=3.8",
"size": 12114,
"upload_time": "2024-12-13T18:38:01",
"upload_time_iso_8601": "2024-12-13T18:38:01.839930Z",
"url": "https://files.pythonhosted.org/packages/aa/1f/737e504e3b0fd41a56e7cdf03436a249ac7ae9db9c279626855f7ce54868/arize_otel-0.7.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-12-13 18:38:01",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "Arize-ai",
"github_project": "arize-otel-python",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "arize-otel"
}