Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@patmaddox
Copy link
Contributor

Change description

This adds a finch_pools key to the Grafana config, to be passed as the pools key to Finch.start_link/1.

What problem does this solve?

We connect to our Grafana instance over an HTTP proxy. Configuring a proxy in Finch requires passing connection opts to the underlying Mint library.

Example usage

config :our_app, OurApp.PromEx,
  disabled: false,
  grafana: [
    host: System.fetch_env!("GRAFANA_HOST"),
    auth_token: System.fetch_env!("GRAFANA_API_KEY"),
    finch_pools: %{
      default: [
        conn_opts: [
          proxy: {:http, "localhost", 8080, []}
        ]
      ]
    }
  ],

Additional details and screenshots

This bumps the Finch dependency, because v0.12.0 adds "support for Mint.UnsafeProxy connections". I opted to bump to the latest 0.13.0.

Checklist

  • I have added unit tests to cover my changes.
  • I have added documentation to cover my changes.
  • My changes have passed unit tests and have been tested E2E in an example project.

- Git SHA of the last commit (if the GIT_SHA environment variable is present)
- Git author of the last commit (if the GIT_AUTHOR environment variable is present)
* `:finch_pools` - (optional) A map that will be passed to Finch.start_link/1 as the :pools key,
Copy link
Contributor Author

@patmaddox patmaddox Sep 15, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I opted for finch_pools rather than finch: [ pools: ... ] for two reasons:

  1. Finch.start_link/1 only defines two options: name and pools. If they add more options at some point, this could get messy - but if that happened, we could consider changing this to just finch.
  2. More importantly, PromEx.grafana_client_child_spec/4 passes :name to GrafanaClient.child_spec/, which passes it to Finch.

This would lead to some ambiguity if you did e.g. finch: [ name: MyApp, pools: %{ ... }].

It's possible to address - maybe just set a default name if the Finch options key doesn't exist. I just don't know that it's worth it at this point.

finch: [ pools: ... ] is more future-proof though, and I think would be straightforward to do.

Any preference on which it should be?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the way that you have it now it fine given that finch doesn't provide any other configuration options that need to be leveraged. Will merge in as soon as CI passes :)

@coveralls
Copy link

coveralls commented Sep 25, 2022

Coverage Status

Coverage increased (+0.1%) to 79.431% when pulling 2e4c646 on patmaddox:finch_pools into c2e0924 on akoutmos:master.

@akoutmos akoutmos merged commit 670e677 into akoutmos:master Sep 25, 2022
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