Skip to content

Name collision with multiple pools #5

@dup2

Description

@dup2

When having multiple connection pools (in our case due to multiple separate databases being used) we get a name collision for the name field which is used in the tags:

Our list of connections db_config is like this:

::ActiveRecord::Base.connection_handler.connection_pool_list(:all).map(&:db_config)

[#<ActiveRecord::DatabaseConfigurations::UrlConfig env_name=production name=primary adapter_class=ActiveRecord::ConnectionAdapters::PostgreSQLAdapter>,
 #<ActiveRecord::DatabaseConfigurations::UrlConfig env_name=archive name=primary adapter_class=ActiveRecord::ConnectionAdapters::PostgreSQLAdapter>]

Now the code in https://github.com/yabeda-rb/yabeda-activerecord/blob/master/lib/yabeda/active_record.rb iterates over these and sets tags based on the name with tags = { config: name }. The names are all equal here ("primary") and this results in a clash and thus only the values of the last connection pool are provided.

I propose to change this to take the env_name into consideration and also think about renaming the tag. I see three different labels which might be of interest: env_name which is in our case the database name, name which is by default primary if not given otherwise and maybe even role which seems to be writing by default if not specified at all.

What do you think about this? I could propose a PR which adds the env_name to the tags when available to improve this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions