From ff97dc49a9d3b862e7fea25945c2d230ab0f64da Mon Sep 17 00:00:00 2001 From: saartochner Date: Mon, 11 Sep 2023 20:01:08 +0300 Subject: [PATCH] add django, and modernize flask with content --- .../instrumentations/django/__init__.py | 6 ++++-- src/lumigo_opentelemetry/instrumentations/flask/__init__.py | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/lumigo_opentelemetry/instrumentations/django/__init__.py b/src/lumigo_opentelemetry/instrumentations/django/__init__.py index 2e4cce45..1fcf73ce 100644 --- a/src/lumigo_opentelemetry/instrumentations/django/__init__.py +++ b/src/lumigo_opentelemetry/instrumentations/django/__init__.py @@ -19,7 +19,7 @@ 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", @@ -27,7 +27,9 @@ def request_hook(span: Span, request: HttpRequest): ) 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", diff --git a/src/lumigo_opentelemetry/instrumentations/flask/__init__.py b/src/lumigo_opentelemetry/instrumentations/flask/__init__.py index b360234d..be9a705e 100644 --- a/src/lumigo_opentelemetry/instrumentations/flask/__init__.py +++ b/src/lumigo_opentelemetry/instrumentations/flask/__init__.py @@ -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",