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

Allow a configurable prefix to prepend the metric #10

Closed
wants to merge 1 commit into from

Conversation

objectuser
Copy link
Contributor

Note: I have an alternative approach in another PR coming.

I added a Modifiers module to house the prefix. This could be enhanced with other modifiers or merged into the Context module.

config :metrix,
  metric_prefix: "my-prefix."


```elixir
config :metrix,
metric_prefix: "my-prefix."
Copy link
Owner

Choose a reason for hiding this comment

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

Can we remove the metric_ part of the name here (and throughout) to be consistent w/ how we're handling the global context?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it was only for clarity wrt what is being prefixed.

@@ -22,6 +24,18 @@ defmodule Metrix do
end
end

defp initial_modifiers do
Copy link
Owner

Choose a reason for hiding this comment

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

What's the purpose of this pass-through function? Seems like we only need one function to get the initial modifiers.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right, I was thinking ahead and got lost.

@@ -0,0 +1,38 @@
defmodule Metrix.Modifiers do
Copy link
Owner

Choose a reason for hiding this comment

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

I like the idea of having a single Agent handle all global state (context and prefix). If you want to do that, I'd be 👍

Wonder if it should be a separate PR so we don't conflate things?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes sense to me.

end

defp metric_prefix_modifier(modifiers) do
case Application.get_env(:metrix, :metric_prefix) do
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thinking that having the :metric_prefix (or, now, :prefix) atom in both modules is a bit of a code smell.

Configure it like this:

```
config :metrix,
  prefix: "my-prefix."
```
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.

None yet

2 participants