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
Added custom tags for MVC metrics #572
Conversation
public Iterable<Tag> getTags(HttpServletRequest request, HttpServletResponse response, Object handler, Throwable exception) { | ||
// add tags only if enabled and the request is for PXF service endpoints (not actuator ones) | ||
if (!customTagsEnabled || StringUtils.isBlank(request.getHeader("X-GP-USER"))) { | ||
return EMPTY_TAGS; |
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.
why not just Tags.empty()
which is probably already an object that was built once, no?
|
||
@Override | ||
public Iterable<Tag> getLongRequestTags(HttpServletRequest request, Object handler) { | ||
return new ArrayList<>(); |
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.
did you try with long requests tags ? maybe there is no issue if we mark our controller as long request?
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.
Actually I think our requests are long requests, and we should probably mark them as such, and we should probably implement this method instead. Both read and write are considered long requests according to the documentation. All other requests (actuator, health) won't have the headers anyway, so nothing to add there.
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.
I don't yet understand the difference, I can't believe the only difference would be some arbitrary duration boundary, need more research there.
@@ -51,11 +53,6 @@ | |||
@Mock | |||
private RequestContext mockContext; | |||
|
|||
@BeforeAll | |||
public static void init() { | |||
System.setProperty("pxf.logdir", "/tmp"); |
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.
yay! did you want to default pxf.logdir to /tmp as part of this PR?
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.
only defaulted for my tests, I can rebase and remove this altogether and default to /tmp in application.properties
/** | ||
* Bean name of PXF's {@link TaskExecutor}. | ||
*/ | ||
public static final String PXF_RESPONSE_STREAM_TASK_EXECUTOR = "pxfResponseStreamTaskExecutor"; | ||
private static final Logger LOG = LoggerFactory.getLogger(PxfConfiguration.class); | ||
private static final Tags EMPTY_TAGS = Tags.empty(); |
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.
|
||
private Tags addTag(String tag, String value, Tags tags, String defaultValue) { | ||
value = StringUtils.defaultIfBlank(value, defaultValue); | ||
if (StringUtils.isNotBlank(value)) { |
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.
this check is no longer necessary
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.
ah, yes, thank you for the catch, now I can remove the private method !
|
||
@Override | ||
public Iterable<Tag> getLongRequestTags(HttpServletRequest request, Object handler) { | ||
return new ArrayList<>(); |
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.
can we return Tags.empty()
here, if we are not going to use it?
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.
it looks good, but there seems there's a unit test failing in CI
PXF is now capable of applying custom tags to metrics reported by Spring MVC. These tags are:
user
,segment
,profile
,server
and will be applied to metrics such ashttp.server.requests
.However, due to a problem with Prometheus integration (micrometer-metrics/micrometer#2399), these tags have to be applied to all endpoints, so the actuator endpoints that receive calls not from Greenplum, will have these tags applied with the values
unknown
.