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

Add Observation instrumentation for gRPC client and server #3427

Merged
merged 1 commit into from Oct 3, 2022

Conversation

ttddyy
Copy link
Contributor

@ttddyy ttddyy commented Sep 23, 2022

This PR adds two gRPC interceptors - ObservationGrpcClientInterceptor and ObservationGrpcServerInterceptor.

I tried to match the data collecting from Observation similar to Sleuth/Brave for spans and existing instrumentation(MetricsCollecting[Client|Server]Interceptor).

For metrics, it is slightly different due to the underlying Observation infrastructure and DefaultMeterObservationHandler.

The existing interceptors create these metrics:

  • grpc.client.requests.sent (Counter)
  • grpc.client.responses.received (Counter)
  • grpc.client.processing.duration (Timer)
  • grpc.server.requests.sent (Counter)
  • grpc.server.responses.received (Counter)
  • grpc.server.processing.duration (Timer)

The new Observation based interceptors creates metrics:

  • grpc.client.received (Counter)
  • grpc.client.sent (Counter)
  • grpc.client (Timer)
  • grpc.client.active (LongTaskTimer)
  • grpc.server.received (Counter)
  • grpc.server.sent (Counter)
  • grpc.server (Timer)
  • grpc.server.active (LongTaskTimer)

The spans are nearly equivalent to what Brave provide.

image

The existing instrumentation does not have a test.
I have added one for the new interceptors that covers all GRPC use cases, 1:1, 1:stream, stream:1, stream:stream with success and failure patterns.

@marcingrzejszczak marcingrzejszczak added the enhancement A general enhancement label Sep 26, 2022
@marcingrzejszczak marcingrzejszczak added this to the 1.10.0-RC1 milestone Sep 26, 2022
Copy link
Contributor

@marcingrzejszczak marcingrzejszczak left a comment

Choose a reason for hiding this comment

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

Added 1 small remark but other than that this looks great!

@sonatype-lift
Copy link
Contributor

sonatype-lift bot commented Sep 26, 2022

⚠️ 10 God Classes were detected by Lift in this project. Visit the Lift web console for more details.

*
* @author Tadaya Tsuyukubo
*/
public class GrpcObservationSample {
Copy link
Member

Choose a reason for hiding this comment

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

Should we move this to micrometer-samples or keep it here?
I'm totally fine keeping it since it is quite simple.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For now, keeping it here.
When all sample classes move to micrometer-samples, this goes as well.

* @author Tadaya Tsuyukubo
* @since 1.10.0
*/
public enum GrpcObservation implements ObservationDocumentation {
Copy link
Member

Choose a reason for hiding this comment

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

Since DocumentedObservation was renamed to ObservationDocumentation, should we rename GrpcObservation to to reflect that it is a documentation?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Renamed to GrpcObservationDocumentation to align with existing other documentation classes.

Add Observation instrumentation for gRPC client and server.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement A general enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants