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

Inteface Changes/Updates #1

Closed
gorzell opened this issue Dec 27, 2011 · 1 comment
Closed

Inteface Changes/Updates #1

gorzell opened this issue Dec 27, 2011 · 1 comment
Assignees

Comments

@gorzell
Copy link
Contributor

gorzell commented Dec 27, 2011

// Restrict set of metrics that get polled
public interface IMetricFilter {
boolean matches(String name, Map<String,String> tags);
}

// Poll a set of metrics from some source, replaces current callback mechanism
// can have implementations for MonitoredResource, Tomcat, Apache, Jvm, ...
public interface IMetricPoller {
void poll(IMetricFilter filter, IMetricWriter writer);
}

// Output source to write metrics
// implementations for epic, cloudwatch, ...
public interface IMetricWriter {
void write(Metric metric);
void close();
}

// Register objects with monitor annotations to some storage, main implementation for jmx
public interface IMonitorRegistry {
void registerObject(Object obj);
void unRegisterObject(Object obj);
}

I'm going to create a few filter and poller implementations to make sure those interfaces will work for what I need, so I may still change them a bit. Annotations:

For the data source type I removed some of the types such as DERIVE, ABSOLUTE, and BOOLEAN. DERIVE and ABSOLUTE come from RRD and are special counter types. COUNTER automatically gets converted to DERIVE right now internally and is the right behavior most of the time. I chose to keep the COUNTER name in the ds type enum because I think it is more intuitive for the user. ABSOLUTE doesn't seem to be used by anybody right now and BOOLEAN doesn't offer any benefit over INFORMATIONAL.

public enum DataSourceType {
GAUGE,
COUNTER,
INFORMATIONAL
}

Monitor and MonitorId are pretty much the same except I added tags to the Monitor annotation. Format is array of strings with "=" as we discussed before.

@retention(RetentionPolicy.RUNTIME)
@target({ElementType.FIELD, ElementType.METHOD})
public @interface Monitor {
public String name();
public DataSourceType type() default DataSourceType.INFORMATIONAL;
public String[] tags() default {};
public String description() default "";
}

@retention(RetentionPolicy.RUNTIME)
@target({ElementType.FIELD, ElementType.METHOD})
public @interface MonitorId {
}

I added a MonitorTags annotation that should go on a method or field that returns a Map<String,String>. Like the current MonitorId it will only be queried once during registration to get the tags that should be applied to all metrics for the instance. If the same tag key is provided on the Monitor annotation it will override the value from this annotation on that attribute.

@target({ElementType.FIELD, ElementType.METHOD})
public @interface MonitorTags {
}

I also changed the JMX representation to allow for filtering based on the metadata before the annotated method is ever called. The JMX domain is "com.netflix.monitoring.MonitoredResource" and the attributes for the object name are class=;[instance=;]field=. The class is set to the canonical class name to make it easy to do filtering of resources based on a package. Instance is optional and is set to the value annotated with MonitorId if present to allow multiple instances of a class to be registered with different ids. Field is one of metadata or value. Metadata is a CompositeDataSupport object that has the metadata from the Monitor annotation and can be retrieved without invoking the annotated method. Value is a simple type and is the actual value of the field or return value of a method.

@ghost ghost assigned brharrington Dec 27, 2011
@brharrington
Copy link
Contributor

I pushed my changes to a separate branch, brhdev. You can see the changes from the master branch:

master...brhdev

The only dependency I added was guava. I started from scratch with the interfaces and gradually pulled in things from the old code base so there are quite a few small diffs. My plan is to create a few basic implementations for the main interfaces (filter, poller, writer) to make sure they will work well in practice for my use cases. I'll also add some test cases and comments.

For now I just put everything in the same package since I was mostly worried about the interfaces. I'll clean that up, but I figured I would look at some of the other netflix projects here to see what conventions are used first.

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

No branches or pull requests

2 participants