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

Get all metrics during a single request through the system? #435

Closed
edeandrea opened this issue Feb 18, 2018 · 8 comments
Closed

Get all metrics during a single request through the system? #435

edeandrea opened this issue Feb 18, 2018 · 8 comments
Labels
question A user question, probably better suited for StackOverflow

Comments

@edeandrea
Copy link

Is there a way that I can retrieve all the metrics that were recording during a single http request?

For example with a Spring MVC application - the request comes in, goes through my system (DB calls, other REST/SOAP calls, etc), then leaves. Before it leaves I want to look at all the metrics that were recorded and send them back as part of the response payload/response header/etc, so that on a request-by-request basis I can break down the metrics that way.

@checketts
Copy link
Contributor

Your are describing a use case of Zipkin or Open Tracing. See also Spring Cloud Sleuth.

There could be some instrumentation in Micrometer that easily connects to those systems though.

@edeandrea
Copy link
Author

edeandrea commented Feb 19, 2018

Thanks @checketts . I'm not completely familiar with Zipkin/Sleuth although I have a general understanding of them & what they do. From what I read about Sleuth is that it can be used for tracing requests through a system of dependent microservices. What doesn't jump right out for me from the documentation is that it seems I would have to instrument my code myself (or let Spring do it for me) with the different metrics/spans/etc. It seems (& maybe I just don't have a good enough understanding) that it is metering similar metrics as micrometer.

The particular problem I'm trying to solve is within a single micro service, when I send the response back, I want to collect all of the same metrics that micrometer is already collection (time spent in various places within my current service as well as time spent in external calls my service makes to other dependencies). I want to collect that data & send it back with the current request as either part of the body of the request or in some response header (i.e. not in a log).

It seems that micrometer is already gathering everything I need/want, I just need a "hook" to be able to grab it for the current request.

@edeandrea
Copy link
Author

After looking through the source of micrometer - would my best bet be to implement my own MeterRegistry that was essentially "request-scoped" in the sense that each request would get its own registry that I could pull from when the request was completed?

@checketts
Copy link
Contributor

Yes, that is how I would try to accomplish that (if I couldn't bring in Zipkin)

Use the CompositMeterRegistry and add your own SimpleRegistry that is request scoped.

@edeandrea
Copy link
Author

Thanks @checketts for the information & the quick responses. I'll go ahead and close this out & reach back if I have any further questions.

@jkschneider
Copy link
Contributor

@edeandrea I do want to echo what @checketts said earlier about distributed tracing systems. What you describe really is their wheelhouse. When you look to reason about relative performance of individual subsystems tracing is the way to go.

  • Metrics collectors like Micrometer are optimized for shipping aggregate data over all samples.
  • Tracing collectors are optimized for downsampled representative snapshots of the contribution of each system to end-to-end latency.

@edeandrea
Copy link
Author

edeandrea commented Feb 21, 2018

Hi @jkschneider thanks for the feedback. The main problem I'm having is that our company does not have any of the metrics gathering platforms for distributed tracing through systems, nor do we have a suite of well-connected services that we can trace through using something like Zipkin/Sleuth. We just aren't that mature yet - we will get there some day.

The requirement I'm trying to solve at the moment can be generically stated as "After a request through 1 particular application has concluded, I need the ability to look at all the raw metered metric data that happened during that request".

So for example if a request comes into 1 application & that application makes some REST call and some SOAP call then returns a result, there should be metrics that were captured around durations of the REST & SOAP calls (as well as metadata about those particular calls (i.e. URIs, etc)) as well as duration of the request itself through the system.

Whether or not that is reported as part of the response body/header itself or is sent out to an aggregation platform (i.e. Splunk) can be debated as part of the solution.

We are a Spring Boot shop and will move to Spring Boot 2 once it is out, so micrometer seems like the correct choice for the metrics capture platform. I've played with micrometer-spring-legacy 1.0.0 & can see how powerful & flexible it is. I just need a way to access the raw metrics (not calculated/"histogram-ed"/"percentiled" data) for that particular request so that they can be looked at.

Is that something that Zipkin would give me out of the box (I haven't yet looked into it in detail) for a particular request within a particular application?

@edeandrea edeandrea reopened this Feb 21, 2018
@jkschneider
Copy link
Contributor

Is that something that Zipkin would give me out of the box (I haven't yet looked into it in detail) for a particular request within a particular application?

That's precisely what it's good at.

@jkschneider jkschneider added the question A user question, probably better suited for StackOverflow label Apr 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question A user question, probably better suited for StackOverflow
Projects
None yet
Development

No branches or pull requests

3 participants