a wrapper around `opentelemetry` and `opentelemetry-instrumentation-*` to make life a bit easier
Project description
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
- Creates OTLP exporter if specific env vars (below) are set
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_EXPORTER_OTLP_HEADER |
Looks like Header-Name=header value , where values can contain space ('\x20'). To insert multiple headers, delimit by any other whitespace char. |
NA (no header sent to OTLP endpoint) |
OTEL_EXPORTER_OTLP_INSECURE |
Set to true to disable SSL for OTLP trace exports, or false to always verify. |
NA (follows OpenTelemetry default, which is secure for https and insecure for http) |
OTEL_HEADER_ATTRIBUTES |
HTTP headers to extract as span attributes, split by whitespace. | x-pf-number, x-client-id, x-preferred-username, x-resource-access |
OTEL_LOG_LEVEL |
Log level used by the logging instrumentor (case-insensitive). | info |
OTEL_SERVICE_NAME |
Sets the value of the service.name resource attribute. |
f'{k8s namespace}/{k8s pod name}' or f'{username}@{hostname}.{domain}:<{filename of main}>' |
OTEL_SERVICE_NAMESPACE |
Sets the value of the service.namespace resource attribute. |
f'{k8s namespace}' or None |
OTEL_WRAPPER_DISABLED |
Set to true to disable tracing globally (e.g. when running pytest). |
false (tracing is enabled) |
Note:
Theservice.name
andservice.namespace
can also be set viaOTEL_RESOURCE_ATTRIBUTES
, but any settings there will be overwritten byOTEL_SERVICE_NAME
andOTEL_SERVICE_NAMESPACE
. For more details, read the original OpenTelemetry docs
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for opentelemetry_wrapper-0.0.19.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | f807fbd678adb1536be843aefeeb765e384d8ca84652a8bb6eb16dfd597522b6 |
|
MD5 | 232720c8a37f811b64654694c8307d3a |
|
BLAKE2b-256 | ea2970e141d5fe8bfcadfd50e4b4d915f31b06090bcf25f49c763ea6fa96b9d2 |
Close
Hashes for opentelemetry_wrapper-0.0.19-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e502931054eb6ac3b98fe8bfce9bee75ec47609bf6e75fc148af0e4646d7c020 |
|
MD5 | 6e6e50b3da73793ca312659bdff81558 |
|
BLAKE2b-256 | 7fd960be10e9fd27c9d78d976a2d947ad2cd076bd526eae1593603fa8c49f203 |