Skip to content

Commit

Permalink
sanic: use the lightweight sanic_testing module
Browse files Browse the repository at this point in the history
Signed-off-by: Varsha GS <varsha.gs@ibm.com>
(cherry picked from commit 6ff67a1)
  • Loading branch information
Varsha GS committed Sep 16, 2024
1 parent 6bafd3c commit a4806d3
Show file tree
Hide file tree
Showing 7 changed files with 246 additions and 257 deletions.
12 changes: 4 additions & 8 deletions src/instana/instrumentation/sanic_inst.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,8 @@
from instana.util.traceutils import extract_custom_headers
from instana.propagators.format import Format

if hasattr(sanic.request, "types"):
from sanic.request.types import Request
from sanic.response.types import HTTPResponse
else:
from sanic.request import Request
from sanic.response import HTTPResponse
from sanic.request import Request
from sanic.response import HTTPResponse

@wrapt.patch_function_wrapper("sanic.app", "Sanic.__init__")
def init_with_instana(
Expand Down Expand Up @@ -81,7 +77,7 @@ def request_with_instana(request: Request) -> None:
@app.exception(Exception)
def exception_with_instana(request: Request, exception: Exception) -> None:
try:
if not hasattr(request.ctx, "span"):
if not hasattr(request.ctx, "span"): # pragma: no cover
return
span = request.ctx.span

Expand All @@ -98,7 +94,7 @@ def exception_with_instana(request: Request, exception: Exception) -> None:
@app.middleware("response")
def response_with_instana(request: Request, response: HTTPResponse) -> None:
try:
if not hasattr(request.ctx, "span"):
if not hasattr(request.ctx, "span"): # pragma: no cover
return
span = request.ctx.span

Expand Down
30 changes: 0 additions & 30 deletions tests/apps/sanic_app/__init__.py

This file was deleted.

Loading

0 comments on commit a4806d3

Please sign in to comment.