Skip to content

Conversation

@michaelmcfadyen
Copy link
Contributor

Add a new tag "outcome" to web mvc metrics for both servlet and reactive models. The outcome tag can have 4 possible values based on the http status code of the response.

1xx, 2xx, 3xx -> SUCCESS
4xx -> CLIENT_ERROR
5xx -> SERVER_ERROR
no status code -> UNKNOWN

Related Issue: #13801

@pivotal-issuemaster
Copy link

@michaelmcfadyen Please sign the Contributor License Agreement!

Click here to manually synchronize the status of this Pull Request.

See the FAQ for frequently asked questions.

@pivotal-issuemaster
Copy link

@michaelmcfadyen Thank you for signing the Contributor License Agreement!

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Sep 16, 2018
@wilkinsona wilkinsona added type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged labels Sep 17, 2018
@wilkinsona wilkinsona added this to the 2.x milestone Sep 17, 2018
@mveitas
Copy link

mveitas commented Sep 17, 2018

It would be great to give control to developer to be able to override the default bucketing strategy in someway. In some of the APIs we have, 404 is considered to be a successful outcome.

String outcome;
if (status.is1xxInformational() || status.is2xxSuccessful()
|| status.is3xxRedirection()) {
outcome = "SUCCESS";
Copy link

Choose a reason for hiding this comment

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

These should be constant values or an enum since they are used in multiple places

Copy link

Choose a reason for hiding this comment

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

Should these outcome values be treated the same as OUTCOME_UNKNOWN and made into a constant value to avoid the creation for each request?

Copy link
Member

Choose a reason for hiding this comment

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

These should be constant values or an enum since they are used in multiple places

Perhaps. In terms of main code, they're used once on the MVC side and once on the WebFlux side. Sometimes duplication is preferable to creating an artificial construct that would allow them to be shared.

Copy link
Member

Choose a reason for hiding this comment

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

Should these outcome values be treated the same as OUTCOME_UNKNOWN and made into a constant value to avoid the creation for each request?

Yes, I think so. While the strings themselves aren't a problem, it would be better to avoid creating a new Tag each time.

@michaelmcfadyen Thank you for the pull request. Would you like to make this amendment?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure, will update the PR later today

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated PR to use constants for each outcome tag

@michaelmcfadyen
Copy link
Contributor Author

It would be great to give control to developer to be able to override the default bucketing strategy in someway. In some of the APIs we have, 404 is considered to be a successful outcome.

You can override how the outcome tag is created by providing your own implementation of WebMvcTagsProvider.

@michaelmcfadyen
Copy link
Contributor Author

@wilkinsona I am slightly confused by the build failure as the test failures don't seem to have any relevance to the code changes in my PR. Can you advise?

@wilkinsona
Copy link
Member

@michaelmcfadyen I am a bit confused by them too. I agree that they're unrelated to these changes. Please just ignore them. I think we have all we need now to be able to merge this. Thanks again for the PR.

@wilkinsona wilkinsona self-assigned this Sep 18, 2018
wilkinsona added a commit that referenced this pull request Sep 18, 2018
* gh-14486:
  Polish "Add outcome tag to MVC and WebFlux HTTP request metrics"
  Add outcome tag to MVC and WebFlux HTTP request metrics
@wilkinsona
Copy link
Member

@michaelmcfadyen Thank you very much for making your first contribution to Spring Boot. The proposed changes have now been merged into master. I also applied a little bit of polish, the main parts of which were to update the documentation and to divide the success outcome up to separate out informational and redirection.

@wilkinsona wilkinsona modified the milestones: 2.1.x, 2.1.0.M4 Sep 18, 2018
@wilkinsona wilkinsona changed the title Add outcome tag to web mvc servlet and reactive metrics. Fixes gh-13801. Add outcome tag to Web MVC and reactive metrics Sep 18, 2018
izeye added a commit to izeye/micrometer that referenced this pull request Sep 29, 2018
jkschneider pushed a commit to micrometer-metrics/micrometer that referenced this pull request Oct 4, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: enhancement A general enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants