Skip to content

Commit

Permalink
Add http.path tag to tracing
Browse files Browse the repository at this point in the history
  • Loading branch information
dkraczkowski committed Mar 1, 2022
1 parent f3f8d76 commit d0cf58a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,15 @@
# Chocs-Trace <br> [![PyPI version](https://badge.fury.io/py/chocs-middleware.trace.svg)](https://pypi.org/project/chocs-middleware.trace/) [![CI](https://github.com/kodemore/chocs-trace/actions/workflows/main.yaml/badge.svg)](https://github.com/kodemore/chocs-trace/actions/workflows/main.yaml) [![Release](https://github.com/kodemore/chocs-trace/actions/workflows/release.yml/badge.svg)](https://github.com/kodemore/chocs-trace/actions/workflows/release.yml) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
Http tracing middleware for chocs library.


# Installation

### Poetry:
```bash
poetry add chocs-middleware.trace
```

### Pip:
```bash
pip install chocs-middleware.trace
```
2 changes: 2 additions & 0 deletions chocs_middleware/trace/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,15 @@ def handle(self, request: HttpRequest, next: MiddlewareHandler) -> HttpResponse:
if "x-causation-id" not in request.headers:
request.headers["x-causation-id"] = causation_id

Logger.set_tag("http.path", f"{request.method} {request.path}")
Logger.set_tag("http.request_id", request_id)
Logger.set_tag("http.correlation_id", request_id)
Logger.set_tag("http.causation_id", request_id)

if self._use_sentry:
from sentry_sdk import set_tag

set_tag("http.path", f"{request.method} {request.path}")
set_tag("http.request_id", request_id)
set_tag("http.correlation_id", correlation_id)
set_tag("http.causation_id", causation_id)
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "chocs_middleware.trace"
version = "0.1.0"
version = "0.1.1"
description = "Http tracing middleware for chocs library."
authors = ["Dawid Kraczkowski <dawid.kraczkowski@gmail.com>"]
license = "MIT"
Expand Down

0 comments on commit d0cf58a

Please sign in to comment.