Skip to main content

Jaeger tracing middleware for EcoSystem applications, via OTLP HTTP.

Project description

ekosis-jaeger-http

Jaeger distributed tracing for EcoSystem applications, via OTLP HTTP.

Wires into the EcoSystem middleware system. Every endpoint in a service is automatically traced. No changes to endpoint-code required. 😎


How it works

Every EcoSystem request carries a request_uid, ekosis-jaeger-http uses that UUID as the Jaeger trace ID. One request_uid, one trace, full distributed trace visible across all services.

For regular endpoints, a span opens when the request arrives (before_routing) and closes when the response is sent (after_routing). For buffered endpoints, the receive span is linked to child process spans via the metadata mechanism, so the trace survives the async gap between queuing and processing, including across retries.


Install

pip install ekosis-jaeger-http

Configuration

Set the Jaeger OTLP HTTP endpoint via ECOENV_EXTRA_*:

ECOENV_EXTRA_JAEGER_ENDPOINT=http://your-jaeger-host:4318/v1/traces

The service name in Jaeger auto-derives from {app_name}-{instance} (e.g. tracker-0). No explicit configuration required.


Wiring

Setup helper (recommended)

from ekosis_jaeger_http.setup import initiate_jaeger_tracing

initiate_jaeger_tracing()

One call. Reads ECOENV_EXTRA_JAEGER_ENDPOINT, creates both middleware instances, and registers them with MiddlewareManager and BufferedMiddlewareManager.

Place the call before app.start(), typically at the top of your application's __init__:

from ekosis.application_base          import ApplicationBase
from ekosis_jaeger_http.setup         import initiate_jaeger_tracing

initiate_jaeger_tracing()

# --------------------------------------------------------------------------------
class MyServer(ApplicationBase):
    def __init__(self):
        super().__init__()

# --------------------------------------------------------------------------------
def main():
    with MyServer() as app:
        app.start()

# --------------------------------------------------------------------------------
if __name__ == '__main__':
    main()

Manual wiring

If you need access to the middleware instances directly (for example, to compose with your own middleware):

from ekosis.middleware                      import MiddlewareManager, BufferedMiddlewareManager
from ekosis_jaeger_http                     import JaegerHttpTracingMiddleware
from ekosis_jaeger_http.buffered_middleware import JaegerHttpBufferedTracingMiddleware

tracer = JaegerHttpTracingMiddleware(endpoint="http://your-jaeger-host:4318/v1/traces")
MiddlewareManager().add(tracer)
BufferedMiddlewareManager().add(JaegerHttpBufferedTracingMiddleware(tracer))

JaegerHttpBufferedTracingMiddleware takes the JaegerHttpTracingMiddleware instance as an argument. It is used to retrieve the active receive-span at push time and link the process spans to it.


Span structure

Regular endpoint

One span per request, named with the route key:

tracker.log_request     (trace_id = request_uid)
  |
  +-> request.uid       = "3f2a1b..."
  |
  +-> request.route_key = "tracker.log_request"

Buffered endpoint

The receive span is the root. Each process attempt (including retries) produces a child span linked back to the receive span via the persisted trace and span IDs:

tracker.log_request_fail        (receive span)
  |
  +-> LogRequestFailDTO.process (retries=0, process.success=False)
  |
  +-> LogRequestFailDTO.process (retries=1, process.success=True)

The child span name is the DTO class name + .process. The retries attribute shows which attempt produced the span. process.success=False means the item was returned to the queue for retry or moved to the error queue.


Dependencies

Package Licence
opentelemetry-api Apache 2.0
opentelemetry-sdk Apache 2.0
opentelemetry-exporter-otlp-proto-http Apache 2.0

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ekosis_jaeger_http-0.1.0.tar.gz (5.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ekosis_jaeger_http-0.1.0-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

Details for the file ekosis_jaeger_http-0.1.0.tar.gz.

File metadata

  • Download URL: ekosis_jaeger_http-0.1.0.tar.gz
  • Upload date:
  • Size: 5.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for ekosis_jaeger_http-0.1.0.tar.gz
Algorithm Hash digest
SHA256 d80ef6bf2327e8b40d0a811d33ab25f88200bce5a457212ebfa60a1804cebe3c
MD5 45d1f028036a7e4e3bbfb7fa7dc5187a
BLAKE2b-256 782cca732cf7006914c90b81b0998d1594ad431e11ba3f7acd7b030ab832b942

See more details on using hashes here.

File details

Details for the file ekosis_jaeger_http-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for ekosis_jaeger_http-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 548698c6e0aeadcbd7b4b14e6ec910db1662c5b7408c83bebea636621a7dd63a
MD5 16d60e7763c05077d7f55e8d2c630bea
BLAKE2b-256 e566c8103ea95a35bb40cecdf2a3e663317d3e48423cc418f483ec0701469b1f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page