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

[BUG] Documentation about config_opts accepting an MFA is incorrect? #158

Open
patmaddox opened this issue Aug 4, 2022 · 5 comments
Open
Assignees
Labels
bug Something isn't working

Comments

@patmaddox
Copy link
Contributor

Describe the bug

Documentation for config_opts says: "This option can either accept an MFA that will return a string of the full path where the YAML configuration file is, or a keyword list with options so that PromEx can generate a config file for you."

Looking at the code though, it seems pretty clear that it only supports a keyword list - not an MFA.

Perhaps I'm overlooking something?

To Reproduce

config :my_app, MyApp.PromEx,
  grafana_agent: [
    config_opts: {SomeModule, :foo, []}
  ]

Result:

** (Mix) Could not start application myapp: MyApp.Application.start(:normal, []) returned an error: shutdown: failed to start child: MyApp.PromEx
    ** (EXIT) an exception was raised:
        ** (FunctionClauseError) no function clause matching in Keyword.get/3
            (elixir 1.13.4) lib/keyword.ex:352: Keyword.get({SomeModule, :foo, []}, :scrape_interval, "15s")

Expected behavior

It starts.

Environment

  • Elixir version: Elixir 1.13.4
  • Erlang/OTP version: Erlang/OTP 24

Additional context

fwiw I'm not quite convinced of the usefulness of the MFA option. You end up having to provide a lot of keys that PromEx.Config.extract_opts_for_config/1 sets defaults for.

I think it's probably more useful to specify a custom template when rendering.

@patmaddox patmaddox added the bug Something isn't working label Aug 4, 2022
@akoutmos
Copy link
Owner

akoutmos commented Aug 4, 2022

That is definitely a miss on my part. It's something I wanted to implement but haven't gotten around to it. Looks like I put the cart before the horse on the docs though. Is this something that you would like to tackle? It shouldn't take very long to implement.

@patmaddox
Copy link
Contributor Author

Is this something that you would like to tackle?

I don't think so. We started off by defining our config, assuming the MFA thing would work. The args to MFA essentially duplicate the normal config, but also require adding all the missing keys that PromEx sets by default.

Instead, we found it quite elegant to provide a different template file, as in #159

@yordis
Copy link

yordis commented Apr 20, 2023

@patmaddox do you mind either,

A) Fix the documentation
B) Add support for the MFA?

@patmaddox
Copy link
Contributor Author

Do I mind if you / someone does it? Not at all :) @akoutmos makes the decisions around here though.

@yordis
Copy link

yordis commented May 20, 2023

@patmaddox, my apologies if you felt negative emotions from my comment, @akoutmos needs extra hands since he has other priorities and duties, so I am doing my best to support him as much as possible.

Please don't take it personally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants