Skip to content

metrics refactor#5

Merged
schernysh merged 3 commits intomasterfrom
application-metrics
Sep 19, 2018
Merged

metrics refactor#5
schernysh merged 3 commits intomasterfrom
application-metrics

Conversation

@dhutsalo
Copy link
Copy Markdown
Contributor

added and changed metrics
fixed tests

@ImportResource("classpath:spring-repository-bean.xml")
@EnableAutoConfiguration
@ComponentScan
@Slf4j
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This annotation looks redundant as well, isn't it?

ServiceType type;
static String ID_KEY = "uuid";

protected String METRIC_TAG_PREFIX;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This field is not a static constant so the name should follow usual camel-case naming pattern.

log.error(t.getMessage(), t);
// skip overwrite, report first prebid error
if (t instanceof PrebidException) {
applyMetrics(t);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Perhaps it's better to move this logic to handleErrorMetrics ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

will do this later, it'll take some time to re-factor

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Agreed

@Component
public class GraphiteMetricsRecorder extends MetricsRecorder
{
protected static final String PREFIX_PLACEHOLDER = "prefix";
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

For expressiveness I would recommend making prefix more discernible, for example ${prefix} or alike.

JSON_REQUEST_RATE("json-request_rate"),
XML_REQUEST_RATE("xml-request_rate");
REQUEST_DURATION("pbc.prefix.request.duration"),
REQUEST_RATE("pbc.prefix.request"),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Now that we got rid of _rate suffix in metric name it's better to remove _RATE suffix from enum names as well to avoid confusion. This applies to names following too.

REQUEST_INVALID_RATE("request.invalid"),
JSON_RATE("pbc.prefix.json"),
XML_RATE("pbc.prefix.xml"),
SYSTEM_ERR_RATE("pbc.prefix.err.db");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

To be consistent this one should become ERROR_DB.

XML_RATE("pbc.prefix.xml"),
SYSTEM_ERR_RATE("pbc.prefix.err.db");

@Getter @Setter private String tag;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is @Setter necessary here?

}
}

@Override
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think this is redundant since lombok's @Value takes care of generating these methods. Is there a good reason to replace them with own implementation?

Copy link
Copy Markdown
Contributor Author

@dhutsalo dhutsalo Sep 19, 2018

Choose a reason for hiding this comment

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

there is an issue with tests because of logic in value getter


private <T>Mono<T> handleAerospikeError(Throwable throwable) {
if (throwable instanceof AerospikeException) {
return Mono.error(new RepositoryException(throwable.toString()));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It is a good idea to pass not only exception message to RepositoryException but original exception as well so that it is not lost if someone wants to log it later.

return createReactive().setex(normalizedId, expiry, Json.toJson(wrapper))
.map(payload -> wrapper);
} catch (RedisException e) {
return Mono.error(new RepositoryException(e.toString()));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It is a good idea to pass not only exception message to RepositoryException but original exception as well so that it is not lost if someone wants to log it later. This applies to similar block in findById

@schernysh schernysh merged commit 5625523 into master Sep 19, 2018
@schernysh schernysh deleted the application-metrics branch September 19, 2018 15:07
dhutsalo pushed a commit that referenced this pull request Oct 30, 2018
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.

2 participants