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

Orbit Metrics Round 2 #73

Merged
merged 46 commits into from Jun 25, 2015
Merged

Orbit Metrics Round 2 #73

merged 46 commits into from Jun 25, 2015

Conversation

FieldFlux
Copy link

This PR provides a wrapper around Dropwizard's metrics library.

Fields or Methods tagged with @ExportMetric can be registered to emit metrics to a variety of sources via Reporters. In this PR, wrappers are provided for emitting metrics to SL4J, JMX, Graphite, and Ganglia. Reporters can be configured via orbit.yaml like so:

orbit.metrics.reporters:
  - !!com.ea.orbit.metrics.config.Slf4jReporterConfig
    period: 1
    periodUnit: 'MINUTES'
    prefix: 'chat.chat-backend'
  - !!com.ea.orbit.metrics.config.JmxReporterConfig {}

Standard configuration management tools can be used to modify the prefix on a host-by-host manner when deploying by modifying this file.

An Orbit Container Module is provided to setup metrics on the JVM if actors is not being used. The Actors Module will also attempt to setup metrics. If Container is not being used, MetricsManager can be provided a set of ReporterConfig objects using the initializeMetrics() method. This should be done before Stage startup if actors is being used.

Metrics must be registered using the MetricsManager registerExportedMetrics method. A instanceId may be provided so that instance metrics can be setup.

Metrics must be uniquely named. Currently, metrics are named using the name of the class they are defined in plus the name provided via the ExportMetric annotation. For example a metric in ca.fieldflux.awesomeapp.neatclass with a field annotated with

@ExportMetric(name="coolmetric")

would generate a metric named:

ca.fieldflux.awesomeapp.neatclass.coolmetric

Instance Metrics can be used where there may be more than one instance of a class and metrics must be tracked per-instance. To mark a metric as an instance metric use:

@ExportMetric(name="coolmetric", isInstanceMetric=true)

and provide an instanceId when registering the object instance. This will insert an instance identifier into the metric name hierarchy like so:

ca.fieldflux.awesomeapp.neatclass.instanceId.coolmetric

An Actors lifetime extension is also provided so that Actors can expose metrics and have them automatically registered and unregistered on actor activation and deactivation respectively.

FieldFlux and others added 30 commits June 2, 2015 21:55
Initial implementation without configurability. Logs to SL4J by default.
Ganglia and Graphite comming soon :)
GraphiteReporter only supporting Integer, Long, String, Float,etc, not
fancy things like AtomicLongs :(
Cleaning up an import incorrectly added to Stage
Removing empty dependency that was accidentally added to commons POM
Initial implementation without configurability. Logs to SL4J by default.
Ganglia and Graphite comming soon :)
GraphiteReporter only supporting Integer, Long, String, Float,etc, not
fancy things like AtomicLongs :(
Cleaning up an import incorrectly added to Stage
Removing empty dependency that was accidentally added to commons POM
@johnou
Copy link

johnou commented Jun 21, 2015

Instead of isInstanceMetric how about "singleton" and default to true (or whatever makes sense)?


public static String sanitizeMetricName(String name)
{
return name.replaceAll("[\\[\\]\\.\\\\/]", ""); //strip illegal characters
Copy link

Choose a reason for hiding this comment

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

Extract into static pattern / compile regex once?

Metrics Manager is now initialized using reflection in Stage.
@FieldFlux
Copy link
Author

I apparently reformatted Stage.java by mistake. Will attempt to fix.

@FieldFlux
Copy link
Author

Should be better now. :)

@JoeHegarty
Copy link
Member

Looks good. I'll merge this shortly if there are no further comments :)

{
try
{
Class.forName("com.ea.orbit.metrics.MetricsManager"); //make sure the metrics manager is on the classpath.
Copy link

Choose a reason for hiding this comment

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

imo redundant check, if the user imports this class they should have the metrics module in the classpath (metrics should be pulled in via the extension pom), should be safe to remove the forname try catch.

@FieldFlux
Copy link
Author

I have removed the redundant checks for Class.ForName in a local commit. Will push after we come to a decision on the naming of instance metrics :)

@JoeHegarty
Copy link
Member

@FieldFlux if you want to push those last remaining items, I'll merge this today.

@FieldFlux
Copy link
Author

Instance metrics are now "Prototype Metrics" and the scope is controlled via an enum on the ExportMetrics annotation.

JoeHegarty pushed a commit that referenced this pull request Jun 25, 2015
@JoeHegarty JoeHegarty merged commit e0b944f into orbit:master Jun 25, 2015
@FieldFlux FieldFlux deleted the metricsredux branch June 25, 2015 17:29
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

4 participants