# -*- coding: utf-8 -*-
from setuptools import setup

packages = \
['splunk_otel', 'splunk_otel.cmd', 'splunk_otel.site']

package_data = \
{'': ['*']}

install_requires = \
['opentelemetry-api>=0.14b0,<0.15',
 'opentelemetry-exporter-zipkin>=0.14b0,<0.15',
 'opentelemetry-instrumentation>=0.14b0,<0.15',
 'opentelemetry-sdk>=0.14b0,<0.15']

entry_points = \
{'console_scripts': ['splk-py-trace = splunk_otel.cmd.trace:run',
                     'splk-py-trace-bootstrap = splunk_otel.cmd.bootstrap:run']}

setup_kwargs = {
    'name': 'splunk-opentelemetry',
    'version': '0.1.8',
    'description': 'The Splunk distribution of OpenTelemetry Python Instrumentation provides a Python agent that automatically instruments your Python application to capture and report distributed traces to SignalFx APM.',
    'long_description': "# Splunk distribution of OpenTelemetry Python\n\nThe Splunk distribution of [OpenTelemetry Python](https://github.com/open-telemetry/opentelemetry-python)\nprovides multiple installable packages that automatically instruments your Python application to capture and report\ndistributed traces to SignalFx APM.\n\nThis Splunk distribution comes with the following defaults:\n\n- [B3 context propagation](https://github.com/openzipkin/b3-propagation).\n- [Zipkin exporter](https://zipkin.io/zipkin-api/#/default/post_spans)\n  configured to send spans to a locally running [SignalFx Smart\n  Agent](https://docs.signalfx.com/en/latest/apm/apm-getting-started/apm-smart-agent.html)\n  (`http://localhost:9080/v1/trace`).\n- Unlimited default limits for [configuration options](#trace-configuration) to support full-fidelity traces.\n\n> :construction: This project is currently in **BETA**.\n\n## Getting Started\n\nThe instrumentation works with Python version 3.5+. Supported\nlibraries are listed\n[here](https://github.com/open-telemetry/opentelemetry-python/tree/master/instrumentation).\n\nTo get started, install the `splunk-opentelemetry` package, run the bootstrap script and wrap your run command with `splk-py-trace`.\n\nFor example, if the runtime parameters were:\n\n```\npython main.py --port=8000\n```\n\nThen the runtime parameters should be updated to:\n\n```\n$ pip install splunk-opentelemetry\n$ splk-py-trace-bootstrap\n$ SPLK_SERVICE_NAME=my-python-app \\\n    splk-py-trace python main.py --port=8000\n```\n\nThe service name is the only configuration option that typically needs to be\nspecified. A couple other configuration options that may need to be changed or\nset are:\n\n* Endpoint if not sending to a locally running Smart Agent with default\n  configuration\n* Environment attribute (example:\n  `OTEL_RESOURCE_ATTRIBUTES=environment=production`) to specify what\n  environment the span originated from.\n\nInstrumentation works by patching supported libraries at runtime with an\nOpenTelemetry-compatible tracer to capture and export trace spans. The agent\nalso registers an OpenTelemetry `get_tracer` so you can support existing custom\ninstrumentation or add custom instrumentation to your application later.\n\nTo see the Python instrumentation in action with sample applications, see our\n[examples](https://github.com/signalfx/tracing-examples/tree/master/signalfx-tracing/splunk-otel-python).\n\n## All configuration options\n\n### Zipkin exporter\n\n| Environment variable          | Default value                        | Notes                                                                |\n| ----------------------------- | ------------------------------------ | -------------------------------------------------------------------- |\n| OTEL_EXPORTER_ZIPKIN_ENDPOINT | `http://localhost:9080/v1/trace`     | The Zipkin endpoint to connect to. Currently only HTTP is supported. |\n| SPLK_SERVICE_NAME             | `unnamed-python-service`             | The service name of this JVM instance.                               |\n\n### Trace configuration\n\n| Environment variable          | Default value  | Purpose                                                                                                                                                                                                                                                                                                                                                                                                   |\n| ----------------------------- | -------------- | ------------------------------------------------------------------------------------                                                                                                                                                                                                                                                                                                                      |\n| SPLK_MAX_ATTR_LENGTH          | 1200            | Maximum length of string attribute value in characters. Longer values are truncated.                                                                                                                                                                                                                                                                                                                      |\n| OTEL_RESOURCE_ATTRIBUTES      | unset          | Comma-separated list of resource attributes added to every reported span. <details><summary>Example</summary>`key1=val1,key2=val2`</details>\n| OTEL_TRACE_ENABLED            | `true`         | Globally enables tracer creation and auto-instrumentation.                                                                                                                                                                                                                                                                                                                                                |\n\n## Advanced Getting Started\n\n### Alternative: List requirements instead of installing them\n\nThe `splk-py-trace-bootstrap` command can optionally print out the list of\npackages it would install if you chose. In order to do so, pass\n`-a=requirements` CLI argument to it. For example,\n\n```\nsplk-py-trace-bootstrap -a requirements\n```\n\nWill output something like the following:\n\n```\nopentelemetry-instrumentation-falcon>=0.14b0\nopentelemetry-instrumentation-jinja2>=0.14b0\nopentelemetry-instrumentation-requests>=0.14b0\nopentelemetry-instrumentation-sqlite3>=0.14b0\nopentelemetry-exporter-zipkin>=0.14b0\n```\n\nYou can pipe the output of this command to append the new packages to your\nrequirements.txt file or to something like `poetry add`.\n\n## Alternative: Instrument and configure by adding code\n\nIf you cannot use `splk-py-trace` command, you can also add a couple of lines\nof code to your Python application to achieve the same result.\n\n```python\nfrom splunk_otel.tracing import start_tracing\n\nstart_tracing()\n\n# rest of your python application's entrypoint script\n```\n\n### Special Cases:\n\nTODO: Expand on the following special cases\n\n#### Celery\nTracing Celery workers works out of the box when you use the `splk-py-trace` command to start your Python application.\nHowever, if you are instrumenting your celery workers with code, you'll need to make sure you setup tracing for each\nworker by using Celery's `celery.signalfx.worker_process_init` signal. For example:\n\n```python\nfrom splunk_otel.tracing import start_tracing\nfrom celery.signals import worker_process_init\n\n@worker_process_init.connect(weak=False)\ndef on_worker_process_init(*args, **kwargs):\n    start_tracing()\n\n# rest of your python application's entrypoint script\n```\n\n#### Django\nAutomatically instrumenting Django requires `DJANGO_SETTINGS_MODULE` environment variable to be set.\nThe value should be the same as set in your `manage.py` or `wsgi.py` modules. For example, if your manage.py\nfile sets this environment variable to `mydjangoproject.settings` and you start your Django project as\n`./manage.py runserver`, then you can automatically instrument your Django project as follows:\n\n```\nexport DJANGO_SETTINGS_MODULE=mydjangoproject.settings\nsplk-py-trace ./manage.py runserver\n```\n\n#### Gunicorn\nLike Celery, we'll also need to setup tracing per Gunicorn worker. This can be done by setting up tracing inside\nGunicorn's `post_fork()` handler. For exampleL\n\n```python\n# gunicorn.config.py\nfrom splunk_otel.tracing import start_tracing\n\ndef post_fork(server, worker):\n    start_tracing()\n```\n\nThen add `-c gunicorn.config.py` CLI flag to your gunicorn command.\n\n\n## Manually instrument an application\n\nDocumentation on how to manually instrument a Python application is available\n[here](https://opentelemetry-python.readthedocs.io/en/stable/getting-started.html).\n\n## Troubleshooting\n\nEnable debug logging like you would for any Python application.\n\n```python\nimport logging\n\nlogging.basicConfig(level=logging.DEBUG)\n```\n\n> :warning: Debug logging is extremely verbose and resource intensive. Enable\n> debug logging only when needed and disable when done.\n\n# License and versioning\n\nThe Splunk distribution of OpenTelemetry Python Instrumentation is a distribution\nof the [OpenTelemetry Python\nproject](https://github.com/open-telemetry/opentelemetry-python).\nIt is released under the terms of the Apache Software License version 2.0. See\n[the license file](./LICENSE) for more details.\n",
    'author': 'Splunk',
    'author_email': 'splunk-oss@splunk.com',
    'maintainer': None,
    'maintainer_email': None,
    'url': None,
    'packages': packages,
    'package_data': package_data,
    'install_requires': install_requires,
    'entry_points': entry_points,
    'python_requires': '>=3.5,<4.0',
}


setup(**setup_kwargs)
