Metadata-Version: 2.5
Name: opentelemetry-instrumentation-genai-bedrock
Version: 1.2b0
Summary: OpenTelemetry Amazon Bedrock instrumentation
Project-URL: Homepage, https://github.com/open-telemetry/opentelemetry-python-genai/tree/main/instrumentation/opentelemetry-instrumentation-genai-bedrock
Project-URL: Repository, https://github.com/open-telemetry/opentelemetry-python-genai
Author-email: OpenTelemetry Authors <cncf-opentelemetry-contributors@lists.cncf.io>
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.43
Requires-Dist: opentelemetry-instrumentation<1,>=0.64b0
Requires-Dist: opentelemetry-semantic-conventions<1,>=0.64b0
Requires-Dist: opentelemetry-util-genai<2,>=1.2b0
Provides-Extra: instruments
Requires-Dist: boto3<2,>=1.40.46; extra == 'instruments'
Description-Content-Type: text/x-rst

OpenTelemetry Amazon Bedrock Instrumentation
============================================

This package provides OpenTelemetry instrumentation for Amazon Bedrock (via the AWS SDK for Python: ``boto3``, ``botocore``, ``aioboto3``, and ``aiobotocore``),
implementing the OpenTelemetry Generative AI semantic conventions.

Supported Operations
--------------------

* Synchronous and asynchronous chat via the Converse API (``client.converse``)
* Synchronous and asynchronous streaming chat via the ConverseStream API (``client.converse_stream``)
* Synchronous and asynchronous model invocation via the InvokeModel API (``client.invoke_model``)
* Synchronous and asynchronous streaming model invocation via the InvokeModelWithResponseStream API (``client.invoke_model_with_response_stream``)

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

::

    pip install opentelemetry-instrumentation-genai-bedrock

Usage
-----

.. code-block:: python

    import boto3
    from opentelemetry.instrumentation.genai.bedrock import BedrockInstrumentor

    # Enable instrumentation
    BedrockInstrumentor().instrument()

    # Use Bedrock runtime client normally
    client = boto3.client("bedrock-runtime", region_name="us-east-1")
    response = client.converse(
        modelId="amazon.nova-micro-v1:0",
        messages=[{"role": "user", "content": [{"text": "Hello, Bedrock!"}]}],
    )

Configuration
-------------

By default, prompts and completions are not captured. To capture message content, set the
environment variable ``OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT`` to one of
``NO_CONTENT``, ``SPAN_ONLY``, ``EVENT_ONLY``, or ``SPAN_AND_EVENT``:

::

    export OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT=SPAN_ONLY

Prompts and completions can also be redirected via a completion hook by
setting ``OTEL_INSTRUMENTATION_GENAI_COMPLETION_HOOK`` or by passing
``instrument(completion_hook=...)``.

References
----------

* `OpenTelemetry Project <https://opentelemetry.io/>`_
* `OpenTelemetry GenAI semantic conventions <https://opentelemetry.io/docs/specs/semconv/gen-ai/>`_
* `Amazon Bedrock Documentation <https://docs.aws.amazon.com/bedrock/>`_
* `Boto3 Documentation <https://boto3.amazonaws.com/v1/documentation/api/latest/index.html>`_
