openinference-instrumentation-google-genai


Nameopeninference-instrumentation-google-genai JSON
Version 0.1.5 PyPI version JSON
download
home_pageNone
SummaryOpenInference Google GenAI Instrumentation
upload_time2025-07-14 16:52:31
maintainerNone
docs_urlNone
authorNone
requires_python<3.14,>=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.14,>=3.9",
    "maintainer_email": null,
    "keywords": null,
    "author": null,
    "author_email": "OpenInference Authors <oss@arize.com>",
    "download_url": "https://files.pythonhosted.org/packages/d5/04/24d8df2e446bc8b4e25805288e223d481abeb55840f8c6c9df59aa62eef9/openinference_instrumentation_google_genai-0.1.5.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.5",
    "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": "08ad75c43137fb1a5102466dc1846bce97f9b535e7a680ce9f898edc49407c5c",
                "md5": "9695e442997246d40213aa62efdfd33b",
                "sha256": "cc17e01154efc536a0d6dc4abc6e1983c9d26f7ef9f7c6e5822c4e24d4052325"
            },
            "downloads": -1,
            "filename": "openinference_instrumentation_google_genai-0.1.5-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "9695e442997246d40213aa62efdfd33b",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<3.14,>=3.9",
            "size": 22594,
            "upload_time": "2025-07-14T16:52:29",
            "upload_time_iso_8601": "2025-07-14T16:52:29.764974Z",
            "url": "https://files.pythonhosted.org/packages/08/ad/75c43137fb1a5102466dc1846bce97f9b535e7a680ce9f898edc49407c5c/openinference_instrumentation_google_genai-0.1.5-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "d50424d8df2e446bc8b4e25805288e223d481abeb55840f8c6c9df59aa62eef9",
                "md5": "2ed6d9f9da00631e9b9bfc81c881bfb6",
                "sha256": "0872f7c5ac81e6fcbab31739c71fb2ebc1e245bfb99a8d353937df6d8ba884dc"
            },
            "downloads": -1,
            "filename": "openinference_instrumentation_google_genai-0.1.5.tar.gz",
            "has_sig": false,
            "md5_digest": "2ed6d9f9da00631e9b9bfc81c881bfb6",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<3.14,>=3.9",
            "size": 29557,
            "upload_time": "2025-07-14T16:52:31",
            "upload_time_iso_8601": "2025-07-14T16:52:31.024369Z",
            "url": "https://files.pythonhosted.org/packages/d5/04/24d8df2e446bc8b4e25805288e223d481abeb55840f8c6c9df59aa62eef9/openinference_instrumentation_google_genai-0.1.5.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-07-14 16:52:31",
    "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.24661s