Add Plug request ID to telemetry

This commit is contained in:
Shadowfacts 2024-04-25 14:36:31 -04:00
parent 89a60a858c
commit 4c107eb27c
3 changed files with 4 additions and 1 deletions

View File

@ -2,6 +2,7 @@ defmodule TuskerPushWeb.HealthcheckController do
use TuskerPushWeb, :controller
def healthcheck(conn, _params) do
OpenTelemetry.Tracer.set_attribute(:request_id, conn.assigns.request_id)
send_resp(conn, 200, "ok")
end
end

View File

@ -5,6 +5,8 @@ defmodule TuskerPushWeb.PushController do
require Logger
def push(conn, %{"env" => env, "apns_device_token" => apns_device_token, "ctx" => context}) do
OpenTelemetry.Tracer.set_attribute(:request_id, conn.assigns.request_id)
with {:apns_env, apns_env} <- {:apns_env, get_apns_env(env)},
{:encoding, ["aesgcm"]} <- {:encoding, get_req_header(conn, "content-encoding")},
{:body, {:ok, body, conn}} <- {:body, read_body(conn)},

View File

@ -31,7 +31,7 @@ defmodule TuskerPushWeb.Endpoint do
plug Phoenix.CodeReloader
end
plug Plug.RequestId
plug Plug.RequestId, assign_as: :request_id
plug Plug.Telemetry, event_prefix: [:phoenix, :endpoint]
plug Plug.Parsers,