summary refs log tree commit diff
path: root/synapse/media/thumbnailer.py
diff options
context:
space:
mode:
authorEric Eastwood <erice@element.io>2023-07-05 10:22:21 -0500
committerGitHub <noreply@github.com>2023-07-05 10:22:21 -0500
commitce857c05d5f6fa6b66c4a59c4917c440c9b98047 (patch)
tree5beb7f37736f40ed30ef10c2007236d75cb74583 /synapse/media/thumbnailer.py
parentdocs/admin_api: fix header level on 'Users' page (#15852) (diff)
downloadsynapse-ce857c05d5f6fa6b66c4a59c4917c440c9b98047.tar.xz
Add tracing to media `/upload` endpoint (#15850)
Add tracing instrumentation to media `/upload` code paths to investigate https://github.com/matrix-org/synapse/issues/15841
Diffstat (limited to 'synapse/media/thumbnailer.py')
-rw-r--r--synapse/media/thumbnailer.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/synapse/media/thumbnailer.py b/synapse/media/thumbnailer.py
index 73d2272f05..2bfa58ceee 100644
--- a/synapse/media/thumbnailer.py
+++ b/synapse/media/thumbnailer.py
@@ -19,6 +19,8 @@ from typing import Optional, Tuple, Type
 
 from PIL import Image
 
+from synapse.logging.opentracing import trace
+
 logger = logging.getLogger(__name__)
 
 EXIF_ORIENTATION_TAG = 0x0112
@@ -82,6 +84,7 @@ class Thumbnailer:
             # A lot of parsing errors can happen when parsing EXIF
             logger.info("Error parsing image EXIF information: %s", e)
 
+    @trace
     def transpose(self) -> Tuple[int, int]:
         """Transpose the image using its EXIF Orientation tag
 
@@ -133,6 +136,7 @@ class Thumbnailer:
                     self.image = self.image.convert("RGB")
         return self.image.resize((width, height), Image.LANCZOS)
 
+    @trace
     def scale(self, width: int, height: int, output_type: str) -> BytesIO:
         """Rescales the image to the given dimensions.
 
@@ -142,6 +146,7 @@ class Thumbnailer:
         with self._resize(width, height) as scaled:
             return self._encode_image(scaled, output_type)
 
+    @trace
     def crop(self, width: int, height: int, output_type: str) -> BytesIO:
         """Rescales and crops the image to the given dimensions preserving
         aspect::