-
Notifications
You must be signed in to change notification settings - Fork 38
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
CASSSIDECAR-216: Capture Metrics for Schema Reporting #204
base: trunk
Are you sure you want to change the base?
Conversation
e1c05cf
to
64a48a3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sarankk , you should also review this patch
return new ToStringBuilder(this, STYLE) | ||
.append(this.organization()) | ||
.append(this.platform()) | ||
.append(this.environment()) | ||
.append(this.application()) | ||
.append(this.cluster()) | ||
.append(this.identifier()) | ||
.toString(); | ||
.toString() | ||
.replaceAll("\\s", ""); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The toString is relatively complex. Is there a test?
@NotNull DeltaGauge started) | ||
{ | ||
String action = " reporting schema for cluster with identifiers " + identifiersProvider; | ||
LOGGER.info("Started" + action); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use the value placeholder of logger to eval lazily. Update the other places too.
LOGGER.info("Started" + action); | |
LOGGER.info("Started {}", action); |
private void process(@NotNull Metadata metadata, | ||
@NotNull DeltaGauge started) | ||
{ | ||
String action = " reporting schema for cluster with identifiers " + identifiersProvider; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can remove the heading space. It should make the error message in the RuntimeException look a bit nicer too.
protected static final String DOMAIN = ServerMetrics.SERVER_PREFIX + ".SchemaReporting"; | ||
protected static final String STARTED = "Started"; | ||
protected static final String FINISHED = "Finished"; | ||
protected static final String DURATION = "Duration"; | ||
protected static final String SIZE = "Size"; | ||
protected static final String TRIGGER = "Trigger"; | ||
protected static final String RESULT = "Result"; | ||
protected static final String UNIT = "Unit"; | ||
protected static final String REQUEST = "Request"; | ||
protected static final String SCHEDULE = "Schedule"; | ||
protected static final String SUCCESS = "Success"; | ||
protected static final String FAILURE = "Failure"; | ||
protected static final String ASPECTS = "Aspects"; | ||
protected static final String MILLISECONDS = "Milliseconds"; | ||
|
||
public final NamedMetric<DeltaGauge> startedRequest; | ||
public final NamedMetric<DeltaGauge> startedSchedule; | ||
public final NamedMetric<DeltaGauge> finishedSuccess; | ||
public final NamedMetric<DeltaGauge> finishedFailure; | ||
public final NamedMetric<Histogram> durationMilliseconds; | ||
public final NamedMetric<Histogram> sizeAspects; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please update the patch to follow the other Metrics class? Let them be consistent. The string constants that are only used once can all be removed.
startedSchedule = NamedMetric.builder(name -> registry.gauge(name, DeltaGauge::new)) | ||
.withDomain(DOMAIN) | ||
.withName(STARTED) | ||
.addTag(TRIGGER, SCHEDULE) | ||
.build(); | ||
startedRequest = NamedMetric.builder(name -> registry.gauge(name, DeltaGauge::new)) | ||
.withDomain(DOMAIN) | ||
.withName(STARTED) | ||
.addTag(TRIGGER, REQUEST) | ||
.build(); | ||
|
||
finishedSuccess = NamedMetric.builder(name -> registry.gauge(name, DeltaGauge::new)) | ||
.withDomain(DOMAIN) | ||
.withName(FINISHED) | ||
.addTag(RESULT, SUCCESS) | ||
.build(); | ||
finishedFailure = NamedMetric.builder(name -> registry.gauge(name, DeltaGauge::new)) | ||
.withDomain(DOMAIN) | ||
.withName(FINISHED) | ||
.addTag(RESULT, FAILURE) | ||
.build(); | ||
|
||
sizeAspects = NamedMetric.builder(registry::histogram) | ||
.withDomain(DOMAIN) | ||
.withName(SIZE) | ||
.addTag(UNIT, ASPECTS) | ||
.build(); | ||
|
||
durationMilliseconds = NamedMetric.builder(registry::histogram) | ||
.withDomain(DOMAIN) | ||
.withName(DURATION) | ||
.addTag(UNIT, MILLISECONDS) | ||
.build(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefer self-describing names over tags. For example, "StartedBySchedule" provides better readability than "Trigger=Schedule.Started". Note that all the tags are combined into this key=value
format at the end.
assertEquals(0L, metrics.startedRequest.metric.getValue()); | ||
assertEquals(1L, metrics.startedSchedule.metric.getValue()); | ||
assertEquals(1L, metrics.finishedSuccess.metric.getValue()); | ||
assertEquals(0L, metrics.finishedFailure.metric.getValue()); | ||
assertEquals(1L, metrics.sizeAspects.metric.getCount()); | ||
assertEquals(13L, metrics.sizeAspects.metric.getSnapshot().getValues()[0]); | ||
assertEquals(1L, metrics.durationMilliseconds.metric.getCount()); | ||
assertTrue(0L <= metrics.durationMilliseconds.metric.getSnapshot().getValues()[0]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use assertJ
assertEquals(1L, metrics.startedRequest.metric.getValue()); // * one execution triggered by request | ||
assertEquals(0L, metrics.startedSchedule.metric.getValue()); // * zero executions triggered by schedule | ||
assertEquals(1L, metrics.finishedSuccess.metric.getValue()); // * one execution resulted in success | ||
assertEquals(0L, metrics.finishedFailure.metric.getValue()); // * zero executions resulted in failure | ||
assertEquals(1L, metrics.sizeAspects.metric.getCount()); // * single number of aspects, | ||
assertEquals(13L, metrics.sizeAspects.metric.getSnapshot().getValues()[0]); // equal to thirteen | ||
assertEquals(1L, metrics.durationMilliseconds.metric.getCount()); // * single duration of execution, | ||
assertTrue(0L <= metrics.durationMilliseconds.metric.getSnapshot().getValues()[0]); // that is non-negative |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use assertJ
SchemaReportingMetrics metrics = this.metrics.server().schemaReporting(); // Validate captured metrics: | ||
assertEquals(0L, metrics.startedRequest.metric.getValue()); // * zero executions triggered by request | ||
assertEquals(1L, metrics.startedSchedule.metric.getValue()); // * one execution triggered by schedule | ||
assertEquals(1L, metrics.finishedSuccess.metric.getValue()); // * one execution resulted in success | ||
assertEquals(0L, metrics.finishedFailure.metric.getValue()); // * zero executions resulted in failure | ||
assertEquals(1L, metrics.sizeAspects.metric.getCount()); // * single number of aspects, | ||
assertEquals(13L, metrics.sizeAspects.metric.getSnapshot().getValues()[0]); // equal to thirteen | ||
assertEquals(1L, metrics.durationMilliseconds.metric.getCount()); // * single duration of execution, | ||
assertTrue(0L <= metrics.durationMilliseconds.metric.getSnapshot().getValues()[0]); // that is non-negative |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use assertJ
(Only the second commit needs to be reviewed, as the first one is being handled separately in #198)