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

Support other formats for metric dimensions #13

Open
Firehed opened this issue Feb 19, 2020 · 2 comments
Open

Support other formats for metric dimensions #13

Firehed opened this issue Feb 19, 2020 · 2 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@Firehed
Copy link
Contributor

Firehed commented Feb 19, 2020

At present, the use of metrics dimensions results in some metrics being emitted in an unexpected way:

Timer(label: "my_event", dimensions: [("foo", "bar")]).recordNanoseconds(someDuration)

will emit a packet roughly like

my_event.foo.bar:123.45|ms

However, using the tag format for dimensions would be more appropriate in many applications:

my_event:123.45|ms#foo:bar

Unfortunately, there's not a standard syntax for tags (see statsd/statsd#619), but I think this could be addressed by having an optional init parameter to specify the format:

enum DimensionFormat {
  case datadog
  case influxdb
  case inline
  // ..
}

class StatsdClient: MetricsFactory {
  public init(eventLoopGroupProvider: EventLoopGroupProvider = .createNew, host: String, port: Int, format: DimensionFormat = .inline) throws {
    // ...
  }
  // ...
}

// User initialization code
let statsdClient = try StatsdClient(host: statsdHost, port: statsdPort, format: .datadog)
MetricsSystem.bootstrap(statsdClient)

It may be preferable to avoid specific vendor names in the enum cases to avoid any sort of endorsement, but I'm confident that could be addressed.

Thoughts?

@tomerd
Copy link
Member

tomerd commented Mar 5, 2020

excellent idea @Firehed, I agree that a configuration option, or ideally a custom formatter would be good solution. would you like to PR?

@tomerd tomerd added enhancement New feature or request good first issue Good for newcomers labels Mar 6, 2020
@ktoso
Copy link
Member

ktoso commented Jun 11, 2020

Sounds like a custom formatter would be pretty good.

Would you want to look into and PR this @Firehed ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants