Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add region and instance id to logger #142

Merged
merged 7 commits into from
Aug 1, 2023
Merged

feat: add region and instance id to logger #142

merged 7 commits into from
Aug 1, 2023

Conversation

abc3
Copy link
Member

@abc3 abc3 commented Jul 28, 2023

This PR adds the region and instance id to the logger metadata for the client/db handlers and manager process.

@abc3 abc3 requested review from a team, chasers and delgado3d July 28, 2023 16:02
@abc3
Copy link
Member Author

abc3 commented Jul 28, 2023

Hey @supabase/dashbit, is there an easy way to globally set up a value in metadata for all processes? For example, it would be nice to see the region and instance id values in all log messages

@josevalim
Copy link
Contributor

Starting from Elixir v1.15, you should be able to set metadata in your config/runtime.exs:

config :logger, :metadata, [...]

@abc3
Copy link
Member Author

abc3 commented Jul 28, 2023

Wow, nice! But we cannot upgrade to v1.15 because one of our dependencies doesn't support this version. We'll try to upgrade it first

@josevalim
Copy link
Contributor

Which dep is problematic?

Anyway, you can also do this in your application.ex:

primary_config = :logger.get_primary_config()
:ok = :logger.set_primary_config(:metadata, Enum.into([...yourmetadata...], primary_config.metadata))

It requires Erlang/OTP 24.

@abc3
Copy link
Member Author

abc3 commented Jul 31, 2023

Which dep is problematic?

the Logflare Erlang client uses Etso, which doesn't work with Erlang 26 due to an old Ecto version

== Compilation error in file lib/ecto/query.ex ==
** (Kernel.TypespecError) lib/ecto/query.ex:430: type dynamic/0 is a built-in type and it cannot be redefined
    (elixir 1.15.4) lib/kernel/typespec.ex:961: Kernel.Typespec.compile_error/2
    (stdlib 5.0.2) lists.erl:1599: :lists.foldl_1/3
    (elixir 1.15.4) lib/kernel/typespec.ex:226: Kernel.Typespec.translate_typespecs_for_module/2

Anyway, you can also do this in your application.ex:

primary_config = :logger.get_primary_config()
:ok = :logger.set_primary_config(:metadata, Enum.into([...yourmetadata...], primary_config.metadata))

It requires Erlang/OTP 24.

That works perfectly, thanks! 🔥

lib/supavisor/client_handler.ex Outdated Show resolved Hide resolved
lib/supavisor/db_handler.ex Outdated Show resolved Hide resolved
lib/supavisor/manager.ex Outdated Show resolved Hide resolved
@abc3 abc3 merged commit 32d72ed into main Aug 1, 2023
2 checks passed
@abc3 abc3 deleted the feat/metadata branch August 1, 2023 08:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants