Take tesla telemetry
authorTim Buchwaldt <tim@buchwaldt.ws>
Sat, 12 Nov 2022 15:11:38 +0000 (16:11 +0100)
committerFloatingGhost <hannah@coffee-and-dreams.uk>
Thu, 15 Dec 2022 01:04:56 +0000 (01:04 +0000)
lib/pleroma/http.ex
lib/pleroma/web/telemetry.ex

index d8028651c881034c9d6cbe3a11bdbf3cc366e5a6..6ae1cdebb02bfdf8c211bddb087e9b76018e9272 100644 (file)
@@ -65,7 +65,7 @@ defmodule Pleroma.HTTP do
     options = put_in(options[:adapter], adapter_opts)
     params = options[:params] || []
     request = build_request(method, headers, options, url, body, params)
-    client = Tesla.client([Tesla.Middleware.FollowRedirects])
+    client = Tesla.client([Tesla.Middleware.FollowRedirects, Tesla.Middleware.Telemetry])
 
     request(client, request)
   end
index d9c54c28f595ec3bf8c60a8b4ce782203e148568..46b5865f73d58b48d2df06a90ca0866bcaefece7 100644 (file)
@@ -92,6 +92,17 @@ defmodule Pleroma.Web.Telemetry do
         reporter_options: [
           buckets: [0.01, 0.025, 0.05, 0.1, 0.2, 0.5, 1, 2.5, 5, 10]
         ]
+      ),
+      distribution(
+        "tesla_request_completed",
+        event_name: [:tesla, :request, :stop],
+        measurement: :duration,
+        tags: [:response_code],
+        tag_values: fn tags -> Map.put(tags, :response_code, tags.env.status) end,
+        unit: {:native, :second},
+        reporter_options: [
+          buckets: [0.01, 0.025, 0.05, 0.1, 0.2, 0.5, 1, 2.5, 5, 10]
+        ]
       )
     ]
   end