openinference-instrumentation-google-genai


Nameopeninference-instrumentation-google-genai JSON
Version 0.1.8 PyPI version JSON
download
home_pageNone
SummaryOpenInference Google GenAI Instrumentation
upload_time2025-10-10 03:49:10
maintainerNone
docs_urlNone
authorNone
requires_python<3.15,>=3.9
licenseNone
keywords
VCS
bugtrack_url
requirements openai python-dotenv grpcio opentelemetry-api opentelemetry-sdk opentelemetry-instrumentation-openai opentelemetry-instrumentation-langchain opentelemetry-exporter-otlp-proto-grpc langchain langgraph typing-extensions phoenix-client openinference-instrumentation-openllmetry
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # OpenInference Google GenAI Instrumentation

Python auto-instrumentation library for GenAI SDK. Traces are fully OpenTelemetry compatible and can be sent to any OpenTelemetry collector for viewing, such as [Arize Phoenix](https://github.com/Arize-ai/phoenix).

## Installation

```shell
pip install -Uqqq openinference-instrumentation-google-genai
```

## Quickstart

Install `openinference-instrumentation-google-genai` and `arize-phoenix`.

```shell
pip install -U \
    openinference-instrumentation-google-genai \
    arize-phoenix \
    opentelemetry-sdk \
    opentelemetry-exporter-otlp \
    "opentelemetry-proto>=1.12.0"
```

Start the `phoenix` server so that it is ready to receive traces.
The `phoenix` server runs entirely on your machine and does not send data over the internet.

```shell
phoenix serve
```

Instrumenting `genai` is simple.

```python
from openinference.instrumentation.google_genai import GoogleGenAIInstrumentor
from opentelemetry.exporter.otlp.proto.grpc.trace_exporter import OTLPSpanExporter
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import SimpleSpanProcessor

endpoint = "http://127.0.0.1:4317"
tracer_provider = TracerProvider()
tracer_provider.add_span_processor(SimpleSpanProcessor(OTLPSpanExporter(endpoint)))

GoogleGenAIInstrumentor().instrument(tracer_provider=tracer_provider)
```

Now, all calls by `generate_content` are instrumented and can be viewed in the `phoenix` UI.

## Progress

This instrumentation is a work in progress

-   [x] parse messages and invocation
-   [ ] capture tool definitions

## More Info

-   [More info on OpenInference and Phoenix](https://docs.arize.com/phoenix)
-   [How to customize spans to track sessions, metadata, etc.](https://github.com/Arize-ai/openinference/tree/main/python/openinference-instrumentation#customizing-spans)
-   [How to account for private information and span payload customization](https://github.com/Arize-ai/openinference/tree/main/python/openinference-instrumentation#tracing-configuration)

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "openinference-instrumentation-google-genai",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<3.15,>=3.9",
    "maintainer_email": null,
    "keywords": null,
    "author": null,
    "author_email": "OpenInference Authors <oss@arize.com>",
    "download_url": "https://files.pythonhosted.org/packages/73/69/6ec693106e35a159c386c333c9e03b828b43db7cc37db42b841a72cfed84/openinference_instrumentation_google_genai-0.1.8.tar.gz",
    "platform": null,
    "description": "# OpenInference Google GenAI Instrumentation\n\nPython auto-instrumentation library for GenAI SDK. Traces are fully OpenTelemetry compatible and can be sent to any OpenTelemetry collector for viewing, such as [Arize Phoenix](https://github.com/Arize-ai/phoenix).\n\n## Installation\n\n```shell\npip install -Uqqq openinference-instrumentation-google-genai\n```\n\n## Quickstart\n\nInstall `openinference-instrumentation-google-genai` and `arize-phoenix`.\n\n```shell\npip install -U \\\n    openinference-instrumentation-google-genai \\\n    arize-phoenix \\\n    opentelemetry-sdk \\\n    opentelemetry-exporter-otlp \\\n    \"opentelemetry-proto>=1.12.0\"\n```\n\nStart the `phoenix` server so that it is ready to receive traces.\nThe `phoenix` server runs entirely on your machine and does not send data over the internet.\n\n```shell\nphoenix serve\n```\n\nInstrumenting `genai` is simple.\n\n```python\nfrom openinference.instrumentation.google_genai import GoogleGenAIInstrumentor\nfrom opentelemetry.exporter.otlp.proto.grpc.trace_exporter import OTLPSpanExporter\nfrom opentelemetry.sdk.trace import TracerProvider\nfrom opentelemetry.sdk.trace.export import SimpleSpanProcessor\n\nendpoint = \"http://127.0.0.1:4317\"\ntracer_provider = TracerProvider()\ntracer_provider.add_span_processor(SimpleSpanProcessor(OTLPSpanExporter(endpoint)))\n\nGoogleGenAIInstrumentor().instrument(tracer_provider=tracer_provider)\n```\n\nNow, all calls by `generate_content` are instrumented and can be viewed in the `phoenix` UI.\n\n## Progress\n\nThis instrumentation is a work in progress\n\n-   [x] parse messages and invocation\n-   [ ] capture tool definitions\n\n## More Info\n\n-   [More info on OpenInference and Phoenix](https://docs.arize.com/phoenix)\n-   [How to customize spans to track sessions, metadata, etc.](https://github.com/Arize-ai/openinference/tree/main/python/openinference-instrumentation#customizing-spans)\n-   [How to account for private information and span payload customization](https://github.com/Arize-ai/openinference/tree/main/python/openinference-instrumentation#tracing-configuration)\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "OpenInference Google GenAI Instrumentation",
    "version": "0.1.8",
    "project_urls": {
        "homepage": "https://github.com/Arize-ai/openinference/tree/main/python/instrumentation/openinference-instrumentation-google-genai"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "fd660145bb91060b7e56f3b0613328458a9bcd14fe12221bc4a8ca589fa9be8e",
                "md5": "4a5e23d7c8d6d2cadc187a2153c2c7c3",
                "sha256": "d9150c2b698da1b594c77149dcbb85dff896d9eec6e60d17b505fe7a4c7ad9db"
            },
            "downloads": -1,
            "filename": "openinference_instrumentation_google_genai-0.1.8-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "4a5e23d7c8d6d2cadc187a2153c2c7c3",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<3.15,>=3.9",
            "size": 23106,
            "upload_time": "2025-10-10T03:48:54",
            "upload_time_iso_8601": "2025-10-10T03:48:54.150359Z",
            "url": "https://files.pythonhosted.org/packages/fd/66/0145bb91060b7e56f3b0613328458a9bcd14fe12221bc4a8ca589fa9be8e/openinference_instrumentation_google_genai-0.1.8-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "73696ec693106e35a159c386c333c9e03b828b43db7cc37db42b841a72cfed84",
                "md5": "98565411ade7ab9eb1555eddbd532ddf",
                "sha256": "f619ed3b3cfddc6a7d50c4a08f0255d7a6dafdcbd802671077bd38ae6a80a78f"
            },
            "downloads": -1,
            "filename": "openinference_instrumentation_google_genai-0.1.8.tar.gz",
            "has_sig": false,
            "md5_digest": "98565411ade7ab9eb1555eddbd532ddf",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<3.15,>=3.9",
            "size": 30399,
            "upload_time": "2025-10-10T03:49:10",
            "upload_time_iso_8601": "2025-10-10T03:49:10.487425Z",
            "url": "https://files.pythonhosted.org/packages/73/69/6ec693106e35a159c386c333c9e03b828b43db7cc37db42b841a72cfed84/openinference_instrumentation_google_genai-0.1.8.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-10-10 03:49:10",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Arize-ai",
    "github_project": "openinference",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "openai",
            "specs": [
                [
                    ">=",
                    "1.0.0"
                ]
            ]
        },
        {
            "name": "python-dotenv",
            "specs": [
                [
                    ">=",
                    "1.0.0"
                ]
            ]
        },
        {
            "name": "grpcio",
            "specs": [
                [
                    ">=",
                    "1.60.0"
                ]
            ]
        },
        {
            "name": "opentelemetry-api",
            "specs": [
                [
                    ">=",
                    "1.22.0"
                ]
            ]
        },
        {
            "name": "opentelemetry-sdk",
            "specs": [
                [
                    ">=",
                    "1.22.0"
                ]
            ]
        },
        {
            "name": "opentelemetry-instrumentation-openai",
            "specs": [
                [
                    ">=",
                    "0.40b0"
                ]
            ]
        },
        {
            "name": "opentelemetry-instrumentation-langchain",
            "specs": [
                [
                    ">=",
                    "0.40b0"
                ]
            ]
        },
        {
            "name": "opentelemetry-exporter-otlp-proto-grpc",
            "specs": [
                [
                    ">=",
                    "1.22.0"
                ]
            ]
        },
        {
            "name": "langchain",
            "specs": [
                [
                    ">=",
                    "0.1.0"
                ]
            ]
        },
        {
            "name": "langgraph",
            "specs": [
                [
                    ">=",
                    "0.0.15"
                ]
            ]
        },
        {
            "name": "typing-extensions",
            "specs": [
                [
                    ">=",
                    "4.8.0"
                ]
            ]
        },
        {
            "name": "phoenix-client",
            "specs": [
                [
                    ">=",
                    "0.1.0"
                ]
            ]
        },
        {
            "name": "openinference-instrumentation-openllmetry",
            "specs": [
                [
                    ">=",
                    "0.1.0"
                ]
            ]
        }
    ],
    "lcname": "openinference-instrumentation-google-genai"
}
        
Elapsed time: 1.17637s