arize-phoenix-otel


Namearize-phoenix-otel JSON
Version 0.5.1 PyPI version JSON
download
home_pageNone
SummaryLLM Observability
upload_time2024-09-17 01:18:58
maintainerNone
docs_urlNone
authorNone
requires_python<3.13,>=3.8
licenseElastic-2.0
keywords explainability monitoring observability
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # arize-phoenix-otel

Provides a lightweight wrapper around OpenTelemetry primitives with Phoenix-aware defaults.

These defaults are aware of environment variables you may have set to configure Phoenix:
- `PHOENIX_COLLECTOR_ENDPOINT`
- `PHOENIX_PROJECT_NAME`
- `PHOENIX_CLIENT_HEADERS`
- `PHOENIX_API_KEY`

# Examples

The `phoenix.otel` module provides a high-level `register` function to configure OpenTelemetry
tracing by setting a global `TracerProvider`. The register function can also configure headers
and whether or not to process spans one by one or by batch.


## Quickstart

```
from phoenix.otel import register
tracer_provider = register()
```

This is all you need to get started using OTel with Phoenix! `register` defaults to sending spans
to an endpoint at `http://localhost` using gRPC.

## Phoenix Authentication

If the `PHOENIX_API_KEY` environment variable is set, `register` will automatically add an
`authorization` header to each span payload.

### Configuring the collector endpoint

There are two ways to configure the collector endpoint:
- Using environment variables
- Using the `endpoint` keyword argument

#### Using environment variables

If you're setting the `PHOENIX_COLLECTOR_ENDPOINT` environment variable, `register` will
automatically try to send spans to your Phoenix server using gRPC.

```
# export PHOENIX_COLLECTOR_ENDPOINT=https://your-phoenix.com:6006

from phoenix.otel import register
tracer_provider = register()
```

#### Specifying the `endpoint` directly

When passing in the `endpoint` argument, **you must specify the fully qualified endpoint**. For
example, in order to export spans via HTTP to localhost, use Pheonix's HTTP collector endpoint:
`http://localhost:6006/v1/traces`. The gRPC endpoint is different: `http://localhost:4317`.

```
from phoenix.otel import register
tracer_provider = register(endpoint="http://localhost:6006/v1/traces")
```

### Additional configuration

`register` can be configured with different keyword arguments:
- `project_name`: The Phoenix project name (or `PHOENIX_PROJECT_NAME` env. var)
- `headers`: Headers to send along with each span payload (or `PHOENIX_CLIENT_HEADERS` env. var)
- `batch`: Whether or not to process spans in batch

```
from phoenix.otel import register
tracer_provider = register(
    project_name="otel-test", headers={"Authorization": "Bearer TOKEN"}, batch=True
)
```

## A drop-in replacement for OTel primitives

For more granular tracing configuration, these wrappers can be used as drop-in replacements for
OTel primitives:

```
from opentelemetry import trace as trace_api
from phoenix.otel import HTTPSpanExporter, TracerProvider, SimpleSpanProcessor

tracer_provider = TracerProvider()
span_exporter = HTTPSpanExporter(endpoint="http://localhost:6006/v1/traces")
span_processor = SimpleSpanProcessor(span_exporter=span_exporter)
tracer_provider.add_span_processor(span_processor)
trace_api.set_tracer_provider(tracer_provider)
```

Wrappers have Phoenix-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.

### Using environment variables

```
# export PHOENIX_COLLECTOR_ENDPOINT=http://localhost:6006

from opentelemetry import trace as trace_api
from phoenix.otel import TracerProvider

tracer_provider = TracerProvider()
trace_api.set_tracer_provider(tracer_provider)
```

#### Specifying the `endpoint` directly

```
from opentelemetry import trace as trace_api
from phoenix.otel import TracerProvider

tracer_provider = TracerProvider(endpoint="http://localhost:4317")
trace_api.set_tracer_provider(tracer_provider)
```

### Further examples

Users can gradually add OTel components as desired:

## Configuring resources

```
# export PHOENIX_COLLECTOR_ENDPOINT=http://localhost:6006

from opentelemetry import trace as trace_api
from phoenix.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

```
# export PHOENIX_COLLECTOR_ENDPOINT=http://localhost:6006

from opentelemetry import trace as trace_api
from phoenix.otel import TracerProvider, BatchSpanProcessor

tracer_provider = TracerProvider()
batch_processor = BatchSpanProcessor()
tracer_provider.add_span_processor(batch_processor)
```

## Specifying a custom GRPC endpoint

```
from opentelemetry import trace as trace_api
from phoenix.otel import TracerProvider, BatchSpanProcessor, GRPCSpanExporter

tracer_provider = TracerProvider()
batch_processor = BatchSpanProcessor(
    span_exporter=GRPCSpanExporter(endpoint="http://custom-endpoint.com:6789")
)
tracer_provider.add_span_processor(batch_processor)
```

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "arize-phoenix-otel",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<3.13,>=3.8",
    "maintainer_email": null,
    "keywords": "Explainability, Monitoring, Observability",
    "author": null,
    "author_email": "Arize AI <phoenix-devs@arize.com>",
    "download_url": "https://files.pythonhosted.org/packages/b6/2e/eaf0ecb9d4c75c234b90ec6a1cef25c883f8d80caadf7ca45588930917ae/arize_phoenix_otel-0.5.1.tar.gz",
    "platform": null,
    "description": "# arize-phoenix-otel\n\nProvides a lightweight wrapper around OpenTelemetry primitives with Phoenix-aware defaults.\n\nThese defaults are aware of environment variables you may have set to configure Phoenix:\n- `PHOENIX_COLLECTOR_ENDPOINT`\n- `PHOENIX_PROJECT_NAME`\n- `PHOENIX_CLIENT_HEADERS`\n- `PHOENIX_API_KEY`\n\n# Examples\n\nThe `phoenix.otel` module provides a high-level `register` function to configure OpenTelemetry\ntracing by setting a global `TracerProvider`. The register function can also configure headers\nand whether or not to process spans one by one or by batch.\n\n\n## Quickstart\n\n```\nfrom phoenix.otel import register\ntracer_provider = register()\n```\n\nThis is all you need to get started using OTel with Phoenix! `register` defaults to sending spans\nto an endpoint at `http://localhost` using gRPC.\n\n## Phoenix Authentication\n\nIf the `PHOENIX_API_KEY` environment variable is set, `register` will automatically add an\n`authorization` header to each span payload.\n\n### Configuring the collector endpoint\n\nThere are two ways to configure the collector endpoint:\n- Using environment variables\n- Using the `endpoint` keyword argument\n\n#### Using environment variables\n\nIf you're setting the `PHOENIX_COLLECTOR_ENDPOINT` environment variable, `register` will\nautomatically try to send spans to your Phoenix server using gRPC.\n\n```\n# export PHOENIX_COLLECTOR_ENDPOINT=https://your-phoenix.com:6006\n\nfrom phoenix.otel import register\ntracer_provider = register()\n```\n\n#### Specifying the `endpoint` directly\n\nWhen passing in the `endpoint` argument, **you must specify the fully qualified endpoint**. For\nexample, in order to export spans via HTTP to localhost, use Pheonix's HTTP collector endpoint:\n`http://localhost:6006/v1/traces`. The gRPC endpoint is different: `http://localhost:4317`.\n\n```\nfrom phoenix.otel import register\ntracer_provider = register(endpoint=\"http://localhost:6006/v1/traces\")\n```\n\n### Additional configuration\n\n`register` can be configured with different keyword arguments:\n- `project_name`: The Phoenix project name (or `PHOENIX_PROJECT_NAME` env. var)\n- `headers`: Headers to send along with each span payload (or `PHOENIX_CLIENT_HEADERS` env. var)\n- `batch`: Whether or not to process spans in batch\n\n```\nfrom phoenix.otel import register\ntracer_provider = register(\n    project_name=\"otel-test\", headers={\"Authorization\": \"Bearer TOKEN\"}, batch=True\n)\n```\n\n## A drop-in replacement for OTel primitives\n\nFor more granular tracing configuration, these wrappers can be used as drop-in replacements for\nOTel primitives:\n\n```\nfrom opentelemetry import trace as trace_api\nfrom phoenix.otel import HTTPSpanExporter, TracerProvider, SimpleSpanProcessor\n\ntracer_provider = TracerProvider()\nspan_exporter = HTTPSpanExporter(endpoint=\"http://localhost:6006/v1/traces\")\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 Phoenix-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### Using environment variables\n\n```\n# export PHOENIX_COLLECTOR_ENDPOINT=http://localhost:6006\n\nfrom opentelemetry import trace as trace_api\nfrom phoenix.otel import TracerProvider\n\ntracer_provider = TracerProvider()\ntrace_api.set_tracer_provider(tracer_provider)\n```\n\n#### Specifying the `endpoint` directly\n\n```\nfrom opentelemetry import trace as trace_api\nfrom phoenix.otel import TracerProvider\n\ntracer_provider = TracerProvider(endpoint=\"http://localhost:4317\")\ntrace_api.set_tracer_provider(tracer_provider)\n```\n\n### Further examples\n\nUsers can gradually add OTel components as desired:\n\n## Configuring resources\n\n```\n# export PHOENIX_COLLECTOR_ENDPOINT=http://localhost:6006\n\nfrom opentelemetry import trace as trace_api\nfrom phoenix.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```\n# export PHOENIX_COLLECTOR_ENDPOINT=http://localhost:6006\n\nfrom opentelemetry import trace as trace_api\nfrom phoenix.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```\nfrom opentelemetry import trace as trace_api\nfrom phoenix.otel import TracerProvider, BatchSpanProcessor, GRPCSpanExporter\n\ntracer_provider = TracerProvider()\nbatch_processor = BatchSpanProcessor(\n    span_exporter=GRPCSpanExporter(endpoint=\"http://custom-endpoint.com:6789\")\n)\ntracer_provider.add_span_processor(batch_processor)\n```\n",
    "bugtrack_url": null,
    "license": "Elastic-2.0",
    "summary": "LLM Observability",
    "version": "0.5.1",
    "project_urls": {
        "Documentation": "https://docs.arize.com/phoenix/",
        "Issues": "https://github.com/Arize-ai/phoenix/issues",
        "Source": "https://github.com/Arize-ai/phoenix"
    },
    "split_keywords": [
        "explainability",
        " monitoring",
        " observability"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "33846f5bddefb2c4bdb48bd6d277ca5838b1b48e2e0f1fc40fb3f490dc27bf57",
                "md5": "df87fa7ea6bdf488d3fa29f96f92914a",
                "sha256": "c80edd7b178920be5b6375754f37c14824aff2d2659d63615d09f2d64bef18b5"
            },
            "downloads": -1,
            "filename": "arize_phoenix_otel-0.5.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "df87fa7ea6bdf488d3fa29f96f92914a",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<3.13,>=3.8",
            "size": 10784,
            "upload_time": "2024-09-17T01:18:57",
            "upload_time_iso_8601": "2024-09-17T01:18:57.156256Z",
            "url": "https://files.pythonhosted.org/packages/33/84/6f5bddefb2c4bdb48bd6d277ca5838b1b48e2e0f1fc40fb3f490dc27bf57/arize_phoenix_otel-0.5.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b62eeaf0ecb9d4c75c234b90ec6a1cef25c883f8d80caadf7ca45588930917ae",
                "md5": "6043216c3f2a943a2faffae1673fb25e",
                "sha256": "7717122db47744aa9da052bf5516e0b5061b38d8a5aecaf90f22ca7f88643b57"
            },
            "downloads": -1,
            "filename": "arize_phoenix_otel-0.5.1.tar.gz",
            "has_sig": false,
            "md5_digest": "6043216c3f2a943a2faffae1673fb25e",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<3.13,>=3.8",
            "size": 9525,
            "upload_time": "2024-09-17T01:18:58",
            "upload_time_iso_8601": "2024-09-17T01:18:58.006349Z",
            "url": "https://files.pythonhosted.org/packages/b6/2e/eaf0ecb9d4c75c234b90ec6a1cef25c883f8d80caadf7ca45588930917ae/arize_phoenix_otel-0.5.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-09-17 01:18:58",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Arize-ai",
    "github_project": "phoenix",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "tox": true,
    "lcname": "arize-phoenix-otel"
}
        
Elapsed time: 1.26251s