Metadata-Version: 2.1
Name: opentelemetry-instrumentation-pubsub
Version: 0.0.1b1
Summary: Instrument Open Telemetry tracing within the GCP PubSub library
Author: Tom Bennett
Author-email: mrtbennett@outlook.com
Maintainer-email: Tom Bennett <mrtbennett@outlook.com>
License: Copyright (c) 2022, <tombennett86@hotmail.co.uk>
        All rights reserved.
        
        Redistribution and use in source and binary forms, with or without
        modification, are permitted provided that the following conditions are met:
        
        * Redistributions of source code must retain the above copyright notice, this
          list of conditions and the following disclaimer.
        
        * Redistributions in binary form must reproduce the above copyright notice,
          this list of conditions and the following disclaimer in the documentation
          and/or other materials provided with the distribution.
        
        * Neither the name of the copyright holder nor the names of its
          contributors may be used to endorse or promote products derived from
          this software without specific prior written permission.
        
        THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
        AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
        IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
        DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
        FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
        DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
        SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
        CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
        OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
        OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
        
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Requires-Python: >=3.7
Description-Content-Type: text/markdown
Provides-Extra: dev
Provides-Extra: test
License-File: LICENCE

# Open Telemetry GCP PubSub Instrumentation for Python

[![CircleCI](https://dl.circleci.com/status-badge/img/gh/tommbee/opentelemetry-python-instrumentation-pubsub/tree/main.svg?style=shield)](https://dl.circleci.com/status-badge/redirect/gh/tommbee/opentelemetry-python-instrumentation-pubsub/tree/main)
[![PyPi version](https://img.shields.io/pypi/v/opentelemetry-instrumentation-pubsub.svg)](https://pypi.org/project/opentelemetry-instrumentation-pubsub/)

This package provides automatic instrumentation for the [`google-cloud-pubsub`](https://pypi.org/project/google-cloud-pubsub/) client library.

## Installation
```bash
pip install opentelemetry-instrumentation-pubsub
```

## Usage
Initiate the instrumentor after configuring your [Open Telemetry](https://opentelemetry.io/docs/instrumentation/python/manual/) trace provider.

```python
from google.cloud import pubsub_v1
from pubsub_opentelemetry import PubSubInstrumentationProvider


# Instrument PubSub
PubSubInstrumentationProvider().instrument()

# Publish creates a span with PubSub specific attributes
with pubsub_v1.PublisherClient() as publisher:
    publisher.publish(topic_name, b'My first message!')

# Subscribe propagates the context from the received message
with pubsub_v1.SubscriberClient() as subscriber:
    subscriber.subscribe(subscription_name, callback)
```
---

## Development

Install dependencies:
```bash
make install
```

Run lint checks:
```bash
make lint
```

Run unit tests:
```bash
make test
```

Run tests against supported Python versions (using tox):
```bash
make tox
```

[License](LICENSE)
