Skip to content

Commit

Permalink
add django, and modernize flask with content
Browse files Browse the repository at this point in the history
  • Loading branch information
saartochner-lumigo committed Sep 11, 2023
1 parent 0cd1db8 commit ff97dc4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 4 additions & 2 deletions src/lumigo_opentelemetry/instrumentations/django/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,17 @@ def install_instrumentation(self) -> None:
from opentelemetry.instrumentation.django import DjangoInstrumentor
from django.http import HttpRequest, HttpResponse

def request_hook(span: Span, request: HttpRequest):
def request_hook(span: Span, request: HttpRequest) -> None:
with lumigo_safe_execute("django request_hook"):
span.set_attribute(
"http.request.headers",
dump_with_context("requestHeaders", request.headers),
)
add_body_attribute(span, request.body, "http.request.body")

def response_hook(span: Span, request: HttpRequest, response: HttpResponse):
def response_hook(
span: Span, request: HttpRequest, response: HttpResponse
) -> None:
with lumigo_safe_execute("django response_hook"):
span.set_attribute(
"http.response.headers",
Expand Down
6 changes: 4 additions & 2 deletions src/lumigo_opentelemetry/instrumentations/flask/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,16 @@ def check_if_applicable(self) -> None:
def install_instrumentation(self) -> None:
from opentelemetry.instrumentation.flask import FlaskInstrumentor

def request_hook(span: Span, flask_request_environ: Dict[str, Any]):
def request_hook(span: Span, flask_request_environ: Dict[str, Any]) -> None:
with lumigo_safe_execute("flask_request_hook"):
span.set_attribute(
"http.request.headers",
dump_with_context("requestHeaders", flask_request_environ),
)

def response_hook(span: Span, status, response_headers):
def response_hook(
span: Span, status: int, response_headers: Dict[str, Any]
) -> None:
with lumigo_safe_execute("flask_response_hook"):
span.set_attribute(
"http.response.headers",
Expand Down

0 comments on commit ff97dc4

Please sign in to comment.