Metadata-Version: 2.1
Name: scopeagent
Version: 0.3.2
Summary: Scope agent for Python
Home-page: https://scope.undefinedlabs.com
Author: Undefined Labs, Inc
Author-email: info@undefinedlabs.com
License: Apache
Platform: UNKNOWN
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3.4
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Development Status :: 3 - Alpha
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Operating System :: OS Independent
Classifier: Topic :: Software Development :: Libraries
Description-Content-Type: text/markdown
Requires-Dist: certifi (>=2018.8.24)
Requires-Dist: opentracing (<3.0,>=2.0.0)
Requires-Dist: six (<2.0,>=1.10.0)
Requires-Dist: urllib3 (>=1.23)
Requires-Dist: wrapt (>=1.10.11)
Provides-Extra: tests
Requires-Dist: mock ; extra == 'tests'
Requires-Dist: pytest ; extra == 'tests'
Requires-Dist: pytest-localserver ; extra == 'tests'
Requires-Dist: requests ; extra == 'tests'
Requires-Dist: psycopg2-binary ; extra == 'tests'
Requires-Dist: sqlalchemy ; extra == 'tests'

# python-agent

Python agent for [Scope](https://scope.undefinedlabs.com)


## Install

    pip install scopeagent


## Usage

First, get an API key from your Scope installation.

Then, prefix your startup command with `scope-run`:

    scope-run python run my_app.py
    scope-run gunicorn myapp.wsgi
    scope-run python -m unittest discover

### Parameters

| Flag | Required? | Default | Description | Environment variable |
|---|:---:|---|---|:---:|
| `-k`, `--apikey` | Y |  | API key tog use when sending data to Scope | `$SCOPE_APIKEY` |
| `-e`, `--api-endpoint` | Y |  | API endpoint of the Scope installation to send data to | `$SCOPE_API_ENDPOINT` |
| `-n`, `--name` | N | `default` | Service name to use when sending data to Scope | `$SCOPE_SERVICE` |
| `-c`, `--commit` | N | `$(git rev-parse HEAD)` | Commit hash to use when sending data to Scope | `$SCOPE_COMMIT_SHA` |
| `-r`, `--repository` | N | `$(git remote get-url origin)` | Repository URL to use when sending data to Scope | `$SCOPE_REPOSITORY` |
| `--root` | N | `$(git rev-parse --show-toplevel)` | Repository root path | `$SCOPE_SOURCE_ROOT` |

Commit, repository, and source root information will automatically be detected if running on CircleCI or Jenkins via environment variables.


### Advanced usage

If the above doesn't work for your specific setup, 
you can also install the Scope Agent by running the following as early as possible 
in your code (as it needs to patch supported libraries):

```python
import scopeagent

agent = scopeagent.Agent(api_key="xxxxxxxx", api_endpoint="https://scope.mycompany.corp")
agent.install()
```

### Supported libraries

Name | Span/event creation | Extract | Inject
-----|:-------------:|:-------:|:------:
[`celery`](http://www.celeryproject.org) | * |  |
[`gunicorn`](https://pypi.org/project/gunicorn/) | * | * |
[`requests`](https://pypi.org/project/requests/) | * | | *
[`unittest`](https://docs.python.org/3/library/unittest.html) | * | |
[`kombu`](https://github.com/celery/kombu) | * | * | *
[`logging`](https://docs.python.org/3/library/logging.html) | * | |


## Development

### Automated Testing
The following environment variables are used for database tests:

* `POSTGRES_DBURL`

## Acknowledgements

Some code is copied from or inspired by Uber's [opentracing-python-instrumentation
](https://github.com/uber-common/opentracing-python-instrumentation) (MIT license). The original copyright notice is maintained in copied files.


