Metadata-Version: 2.4
Name: opentelemetry-instrumentation-google-api-client
Version: 0.1.0
Summary: OpenTelemetry google-api-python-client instrumentation
Project-URL: Repository, https://github.com/federicobond/opentelemetry-instrumentation-google-api-client
Author-email: Federico Bond <federicobond@gmail.com>
License-Expression: Apache-2.0
License-File: LICENSE
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Requires-Python: >=3.10
Requires-Dist: opentelemetry-api~=1.12
Requires-Dist: opentelemetry-instrumentation>=0.50b0
Provides-Extra: instruments
Requires-Dist: google-api-python-client>=2.0.0; extra == 'instruments'
Description-Content-Type: text/x-rst

OpenTelemetry google-api-python-client Instrumentation
======================================================

|pypi|

.. |pypi| image:: https://badge.fury.io/py/opentelemetry-instrumentation-google-api-client.svg
   :target: https://pypi.org/project/opentelemetry-instrumentation-google-api-client/

This library allows tracing requests made through the
`google-api-python-client <https://github.com/googleapis/google-api-python-client>`_
library. Every call to ``HttpRequest.execute`` produces a ``CLIENT`` span named
``gcp.api/<methodId>`` with the following attributes:

* ``rpc.method`` — the fully-qualified API method, e.g. ``storage.buckets.list``
* ``gcp.client.service`` — the GCP service, e.g. ``storage`` (OTel semconv)
* ``http.request.method`` — the HTTP method
* ``server.address`` / ``server.port`` — the request host (port only when non-default)
* ``url.full`` — the request URL, with credentials and sensitive query values
  (e.g. ``X-Goog-Signature``) redacted

On failure the span status is set to ``ERROR`` with ``error.type``, and for
``googleapiclient.errors.HttpError`` the ``http.response.status_code`` is recorded.

Installation
------------

::

     pip install opentelemetry-instrumentation-google-api-client

Usage
-----

.. code-block:: python

    from opentelemetry.instrumentation.google_api_client import (
        GoogleApiClientInstrumentor,
    )
    from googleapiclient.discovery import build

    GoogleApiClientInstrumentor().instrument()

    service = build("storage", "v1")
    service.buckets().list(project="my-project").execute()

References
----------

* `google-api-python-client <https://github.com/googleapis/google-api-python-client>`_
* `OpenTelemetry Project <https://opentelemetry.io/>`_
