diff --git a/lib/supavisor/application.ex b/lib/supavisor/application.ex index c9fe66f4..c8783110 100644 --- a/lib/supavisor/application.ex +++ b/lib/supavisor/application.ex @@ -9,6 +9,17 @@ defmodule Supavisor.Application do @impl true def start(_type, _args) do + primary_config = :logger.get_primary_config() + + :ok = + :logger.set_primary_config( + :metadata, + Enum.into( + [region: System.get_env("REGION"), instance_id: System.get_env("INSTANCE_ID")], + primary_config.metadata + ) + ) + :ok = :gen_event.swap_sup_handler( :erl_signal_server, diff --git a/lib/supavisor/client_handler.ex b/lib/supavisor/client_handler.ex index 55f7da9a..f978428a 100644 --- a/lib/supavisor/client_handler.ex +++ b/lib/supavisor/client_handler.ex @@ -108,12 +108,7 @@ defmodule Supavisor.ClientHandler do Logger.debug("Client startup message: #{inspect(hello)}") {user, external_id} = parse_user_info(hello.payload["user"]) - Logger.metadata( - project: external_id, - user: user, - region: System.get_env("REGION"), - instance_id: System.get_env("INSTANCE_ID") - ) + Logger.metadata(project: external_id, user: user) sni_hostname = try_get_sni(sock) diff --git a/lib/supavisor/db_handler.ex b/lib/supavisor/db_handler.ex index 2d8895f0..2bb98ce7 100644 --- a/lib/supavisor/db_handler.ex +++ b/lib/supavisor/db_handler.ex @@ -31,12 +31,7 @@ defmodule Supavisor.DbHandler do def init(args) do Process.flag(:trap_exit, true) - Logger.metadata( - project: args.tenant, - user: args.user_alias, - region: System.get_env("REGION"), - instance_id: System.get_env("INSTANCE_ID") - ) + Logger.metadata(project: args.tenant, user: args.user_alias) data = %{ id: args.id, diff --git a/lib/supavisor/manager.ex b/lib/supavisor/manager.ex index bb10bf85..c0a13529 100644 --- a/lib/supavisor/manager.ex +++ b/lib/supavisor/manager.ex @@ -45,12 +45,7 @@ defmodule Supavisor.Manager do default_parameter_status: args.default_parameter_status } - Logger.metadata( - project: args.tenant, - user: args.user_alias, - region: System.get_env("REGION"), - instance_id: System.get_env("INSTANCE_ID") - ) + Logger.metadata(project: args.tenant, user: args.user_alias) Registry.register(Supavisor.Registry.ManagerTables, {args.tenant, args.user_alias}, tid)