etishor / Metrics.NET

The Metrics.NET library provides a way of instrumenting applications with custom metrics (timers, histograms, counters etc) that can be reported in various ways and can provide insights on what is happening inside a running application.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Need a way to set root context name programmatically

vchekan opened this issue · comments

It is usual practice for graphite collectors to have configurable prefix for example "staging.#{machine-name}.MyUserAuthenticationApp.Sql.RequestDurationSeconds". I have seen "Metrics.GlobalContextName" configuration parameter, and it is almost what I would like, but I do not want to set machine name in config file, because of possible chaos it can cause if config files will be copy-pasted around or machine change name, etc.

What I would like to have is to be able programmatically set the root context name where I would be able to append machine name. Or, another option is to have "magic param", where "$env.machine-name$" in config would be replaced with actual name.

If given directions, I can implement it and submit pull request.

@vchekan thanks for the suggestion, it makes perfect sense.

Turns out it is very easy to implement support for "magic params". See 93cb122 for details. The params are case insensitive.

I've also changed the default name for the global context name to include the machine name.

For now only $Env.MachineName$ is implemented. Let me know if you think other parameters would make sense. (feel free to send PR with other params if you need them).

Thanks

Closing this, thanks.