Metadata-Version: 2.1
Name: opentelemetry_wrapper
Version: 0.0.11
Summary: a wrapper around `opentelemetry` and `opentelemetry-instrumentation-*` to make life a bit easier
Author-email: Avery Khoo <averykhoo@gmail.com>
Requires-Python: >3.8.0
Description-Content-Type: text/markdown
Classifier: License :: OSI Approved :: Apache Software License
Requires-Dist: asgiref
Requires-Dist: fastapi
Requires-Dist: itsdangerous
Requires-Dist: opentelemetry-api
Requires-Dist: opentelemetry-exporter-otlp
Requires-Dist: opentelemetry-instrumentation-fastapi
Requires-Dist: opentelemetry-instrumentation-logging
Requires-Dist: opentelemetry-instrumentation-requests
Requires-Dist: opentelemetry-instrumentation-sqlalchemy
Requires-Dist: opentelemetry-sdk
Requires-Dist: requests
Requires-Dist: sqlalchemy
Requires-Dist: starlette
Requires-Dist: uvicorn
Project-URL: Home, https://github.com/averykhoo/opentelemetry_wrapper

# opentelemetry_wrapper

a wrapper around `opentelemetry` and `opentelemetry-instrumentation-*` to make life a bit easier

## what this does (or is supposed to do)

* Make instrumentation (more) idempotent
* Make re-instrumentation of logging actually work with different format strings
* Make `logging` print as a one-line JSON dict by default
* Provide support for decorating functions and classes
* Provide support for instrumentation of dataclasses
  * Global instrumentation needs to be run *before* any dataclasses are initialized
  * Otherwise, use the decorator on each class as usual (it's idempotent anyway)
* Add global instrumentation of FastAPI
  * sometimes works even after apps are created for some reason, likely due to how Uvicorn runs in a new process
  * but somehow sometimes doesn't work in prod, for equally unknown reasons
  * probably best to instrument each app instance
* logs some http headers received by fastapi as span attributes

## usage

todo: write stuff here

## env vars

| Variable Name                     | Description                                                          | Default (if not set)                                                |
|-----------------------------------|----------------------------------------------------------------------|---------------------------------------------------------------------|
| `OTEL_EXPORTER_OTLP_ENDPOINT`     | Looks like `http://tempo.localhost:4317`                             | *NA* (traces are not exported to any OTLP endpoint)                 |
| `OTEL_LOG_LEVEL`                  | Log level used by the logging instrumentor                           | `INFO`                                                              |
| `OTEL_RESOURCE_ATTRIBUTES`        | Key-value pairs to be used as resource attributes.                   | *NA*                                                                |
| `OTEL_SERVICE_NAME`               | Sets the value of the `service.name` resource attribute.             | f'{username}@{hostname}.{namespace or domain}:<{filename of main}>' |
| `OTEL_WRAPPER_DISABLED`           | Set to `true` to disable tracing globally (e.g. when running pytest) | `false` (tracing is enabled)                                        |


## read the original docs

* [OpenTelemetry](https://opentelemetry.io/docs)

