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

Added support for Micrometer Observation API #11021

Merged
merged 15 commits into from
Jan 25, 2023

Conversation

marcingrzejszczak
Copy link
Contributor

What is the purpose of the change

Fixes #10742

Brief changelog

  • Updates Micrometer to 1.10.2 via a BOM
  • Adds Micrometer Tracing 1.0.0 via a BOM
  • Adds provide and consumer Observation Filters

Verifying this change

Checklist

  • Make sure there is a GitHub_issue field for the change (usually before you start working on it). Trivial changes like typos do not require a GitHub issue. Your pull request should address just this issue, without pulling in other changes - one PR resolves one issue.
  • Each commit in the pull request should have a meaningful subject line and body.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Check if is necessary to patch to Dubbo 3 if you are work on Dubbo 2.7
  • Write necessary unit-test to verify your logic correction, more mock a little better when cross module dependency exist. If the new feature or significant change is committed, please remember to add sample in dubbo samples project.
  • Add some description to dubbo-website project if you are requesting to add a feature.
  • GitHub Actions works fine on your own branch.
  • If this contribution is large, please follow the Software Donation Guide.

@chickenlj
Copy link
Contributor

Could you please fix the following Checkstyle issue?

[INFO] Starting audit...
Error:  /home/runner/work/dubbo/dubbo/dubbo/dubbo-metrics/dubbo-metrics-api/src/main/java/org/apache/dubbo/metrics/filter/observation/DubboConsumerContext.java:21:8: Unused import - io.micrometer.observation.transport.Kind. [UnusedImports]
Audit done.
[INFO] There is 1 error reported by Checkstyle 8.41 with codestyle/checkstyle.xml ruleset.
Error:  src/main/java/org/apache/dubbo/metrics/filter/observation/DubboConsumerContext.java:[21,8] (imports) UnusedImports: Unused import - io.micrometer.observation.transport.Kind.
[INFO] ------------------------------------------------------------------------

@chickenlj
Copy link
Contributor

I am still new to the Observation API, so I need to learn how it works and what advantages can it bring first.

@marcingrzejszczak
Copy link
Contributor Author

Hey, sure. I first created an issue here #10742 where I described the advantages and got a green light to start working on this. Is there anything else you want me to add other than what's there in the issue?

@marcingrzejszczak
Copy link
Contributor Author

marcingrzejszczak commented Nov 25, 2022

Let me provide an additional explanation.

Thanks to this PR, by properly configuring Micrometer Observation (ObservationRegistry) with Micrometer Tracing (Tracer) and Micrometer Core (MeterRegistry) you can have out of the box metrics and tracing support in Apache Dubbo.

I've managed to configure that for the Boot samples in core and this is the result in Zipkin

Screenshot from 2022-11-25 12-32-12
Screenshot from 2022-11-25 12-31-42

And these are the collected metrics:

Server

==== METRICS ====
 - Metric type 	[LONG_TASK_TIMER],	name [rpc.server.duration.active],	tags [tag(net.peer.name=192.168.68.116), tag(net.peer.port=35898), tag(rpc.method=sayHello), tag(rpc.service=org.apache.dubbo.springboot.demo.DemoService), tag(rpc.system=apache_dubbo)],	measurements [Measurement{statistic='ACTIVE_TASKS', value=0.0}, Measurement{statistic='DURATION', value=0.0}]
 - Metric type 	[TIMER],	name [rpc.server.duration],	tags [tag(error=none), tag(net.peer.name=192.168.68.116), tag(net.peer.port=35898), tag(rpc.method=sayHello), tag(rpc.service=org.apache.dubbo.springboot.demo.DemoService), tag(rpc.system=apache_dubbo)],	measurements [Measurement{statistic='COUNT', value=1.0}, Measurement{statistic='TOTAL_TIME', value=0.022346498}, Measurement{statistic='MAX', value=0.022346498}]
=================

Client

==== METRICS ====
 - Metric type 	[LONG_TASK_TIMER],	name [rpc.client.duration.active],	tags [tag(rpc.method=sayHello), tag(rpc.service=org.apache.dubbo.springboot.demo.DemoService), tag(rpc.system=apache_dubbo)],	measurements [Measurement{statistic='ACTIVE_TASKS', value=0.0}, Measurement{statistic='DURATION', value=0.0}]
 - Metric type 	[TIMER],	name [rpc.client.duration],	tags [tag(error=none), tag(rpc.method=sayHello), tag(rpc.service=org.apache.dubbo.springboot.demo.DemoService), tag(rpc.system=apache_dubbo)],	measurements [Measurement{statistic='COUNT', value=1.0}, Measurement{statistic='TOTAL_TIME', value=0.188515207}, Measurement{statistic='MAX', value=0.188515207}]
=================

I did my best to follow the experimental OpenTelemetry semantic conventions for tracing and metrics

Copy link
Member

@AlbumenJ AlbumenJ left a comment

Choose a reason for hiding this comment

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

Please merge this PR into 3.2 branch for new feature purpose.

Copy link
Member

@AlbumenJ AlbumenJ left a comment

Choose a reason for hiding this comment

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

BTW, a little question. Could be configuration in dubbo-demo be more simplify?

@sonarqubecloud
Copy link

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 12 Code Smells

43.1% 43.1% Coverage
18.2% 18.2% Duplication

@marcingrzejszczak
Copy link
Contributor Author

I can remove the Zipkin dependency from the samples - this will simplify things a little bit. However, if you migrate dubbo to use Spring Boot 3, then most of the configuration will be gone because it's done behind the scenes by Boot.

@marcingrzejszczak marcingrzejszczak changed the base branch from 3.1 to 3.2 November 29, 2022 14:50
@marcingrzejszczak
Copy link
Contributor Author

Rebased my branch on top of 3.2 of dubbo

@marcingrzejszczak
Copy link
Contributor Author

Ok I fixed the provider side, what else should I do to have this PR merged?

@AlbumenJ
Copy link
Member

AlbumenJ commented Dec 5, 2022

@CrazyHZM PTAL

@AlbumenJ AlbumenJ requested a review from CrazyHZM December 5, 2022 03:22
@CrazyHZM
Copy link
Member

CrazyHZM commented Dec 5, 2022

Thanks to @marcingrzejszczak for this contribution, because the content of this PR will directly provide users with the Micrometer Observation function, we need to discuss whether it will be the default implementation of Dubbo, or temporarily used as an SPI EXTENSION(https://github.com/apache/dubbo-spi-extensions). Please give us some time to understand the Micrometer Observation function

@marcingrzejszczak
Copy link
Contributor Author

Sure, if you have any questions I'll be more than happy to answer them.

/**
* Default implementation of the {@link DubboConsumerObservationConvention}.
*/
public class DefaultDubboServerObservationConvention extends AbstractDefaultDubboObservationConvention implements DubboConsumerObservationConvention {
Copy link
Contributor

Choose a reason for hiding this comment

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

Hi, I think DefaultDubboServerObservationConvention should implements DubboProviderObservationConvention, not DubboConsumerObservationConvention

Copy link
Contributor Author

Choose a reason for hiding this comment

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

To tell you the truth I'm completely confused with how dubbo understands receiver and sender (aka client and server aka producer consumer). I think that with this setup I've managed to get proper results in Zipkin (which doesn't mean that I've done this properly)

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, there is no problem with the function, but it may prefer client as consumer semantically

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've changed the names to Server and Client instead of Provider and Consumer

/**
* Default implementation of the {@link DubboProviderObservationConvention}.
*/
public class DefaultDubboClientObservationConvention extends AbstractDefaultDubboObservationConvention implements DubboProviderObservationConvention {
Copy link
Contributor

Choose a reason for hiding this comment

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

Hi, I think DefaultDubboClientObservationConvention should implements DubboConsumerObservationConvention, not DubboProviderObservationConvention

@@ -0,0 +1,2 @@
observationreceiver=org.apache.dubbo.metrics.filter.observation.ObservationReceiverFilter
Copy link
Contributor

Choose a reason for hiding this comment

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

ObservationReceiverFilter is implements Filter, so it needs to be placed in org.apache.dubbo.rpc.Filter, or the ObservationReceiverFilter will not take effect.
When I tested locally, I found that the invoke method of the filter was not called.
image

Copy link
Contributor

Choose a reason for hiding this comment

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

See the comments below I made on Filter and ClusterFilter

Copy link
Contributor

Choose a reason for hiding this comment

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

This needs to be changed, because ObservationReceiverFilter is implements Filter.
As shown in the figure, put it in the configuration file of org.apache.dubbo.rpc.Filter

Copy link
Contributor

Choose a reason for hiding this comment

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

This needs to be changed, because ObservationReceiverFilter is implements Filter. As shown in the figure, put it in the configuration file of org.apache.dubbo.rpc.Filter

Would implementing org.apache.dubbo.rpc.ClusterFilter be better?

Copy link
Contributor

Choose a reason for hiding this comment

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

org.apache.dubbo.rpc.ClusterFilter should be applied to consumer, but ObservationReceiverFilter is provider.
So ObservationReceiverFilter shoule implement Filter

@CrazyHZM
Copy link
Member

CrazyHZM commented Jan 17, 2023

ping @marcingrzejszczak
Please check and process the above review content.

@marcingrzejszczak
Copy link
Contributor Author

Yup, I will, thanks :)


filter.invoke(invoker, invocation);

BDDAssertions.then(RpcContext.getClientAttachment().getAttachment("X-B3-TraceId")).isNotEmpty();
Copy link
Contributor

Choose a reason for hiding this comment

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

Unit test is error in here.
I think DubboClientContext and DubboServerContext should be changed as follows:
image

@CrazyHZM
Copy link
Member

@marcingrzejszczak
Hello, we are actively promoting Dubbo's observability capabilities, including tracing. We have also reviewed the PR and found that there is no problem with the basic content, but there are some problems with the details. These problems may be related to Dubbo's principle.
In addition, we have other new features that need to be iterated, and they are based on this PR. Therefore, interested partners in the community have already solved the problem of this PR for you, and we also plan to merge this PR, then @conghuhu will provide a PR to fix the problem on this PR. Welcome to review that PR at that time, thank you.

@marcingrzejszczak
Copy link
Contributor Author

Great to hear that! I'll try to review this today and then feel free to merge it :)

@marcingrzejszczak
Copy link
Contributor Author

So should I update the PR with your suggestions or I shouldn't touch it at all and just do a review?

@CrazyHZM
Copy link
Member

So should I update the PR with your suggestions or I shouldn't touch it at all and just do a review?

It would of course be best if the issue could be fixed on this PR in time.
@marcingrzejszczak

@codecov-commenter
Copy link

codecov-commenter commented Jan 23, 2023

Codecov Report

Merging #11021 (fca5473) into 3.2 (d28b224) will decrease coverage by 4.83%.
The diff coverage is 72.65%.

@@             Coverage Diff              @@
##                3.2   #11021      +/-   ##
============================================
- Coverage     69.62%   64.80%   -4.83%     
+ Complexity      131       14     -117     
============================================
  Files          1515     1497      -18     
  Lines         82452    62498   -19954     
  Branches      14757     9146    -5611     
============================================
- Hits          57408    40499   -16909     
+ Misses        20201    17763    -2438     
+ Partials       4843     4236     -607     
Impacted Files Coverage Δ
...ion/AbstractDefaultDubboObservationConvention.java 38.88% <38.88%> (ø)
...ation/DefaultDubboClientObservationConvention.java 60.00% <60.00%> (ø)
.../filter/observation/ObservationReceiverFilter.java 73.91% <73.91%> (ø)
...cs/filter/observation/ObservationSenderFilter.java 82.60% <82.60%> (ø)
...metrics/filter/observation/DubboClientContext.java 85.71% <85.71%> (ø)
...metrics/filter/observation/DubboServerContext.java 85.71% <85.71%> (ø)
...o/metrics/filter/observation/DubboObservation.java 88.88% <88.88%> (ø)
...ation/DefaultDubboServerObservationConvention.java 100.00% <100.00%> (ø)
.../observation/DubboClientObservationConvention.java 100.00% <100.00%> (ø)
.../observation/DubboServerObservationConvention.java 100.00% <100.00%> (ø)
... and 488 more

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Copy link
Member

@AlbumenJ AlbumenJ left a comment

Choose a reason for hiding this comment

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

LGTM

@AlbumenJ
Copy link
Member

@marcingrzejszczak Thanks for your kindly contribution. I will merge it later until CI works fine.
After this PR, we still have some things to improve on the metrics part.

  1. For the ObservationConfiguration class provided in the demo project in this PR, we need a detailed document to explain its details and guide users how to configure it in their own Spring or SpringBoot projects. In addition, can we provide a SpringBoot Starter to simplify the configuration difficulty for users.
  2. The current docking is based on the micrometer. For user production deployment, we also need to provide a feasible and sufficiently detailed solution for reporting to zipkin or wavefront through OTEL.

@marcingrzejszczak
Copy link
Contributor Author

For the ObservationConfiguration class provided in the demo project in this PR, we need a detailed document to explain its details and guide users how to configure it in their own Spring or SpringBoot projects. In addition, can we provide a SpringBoot Starter to simplify the configuration difficulty for users.

Actually the whole setup is done manually only because you're not using Boot 3. In Boot 3 all of that is auto-configured.

The current docking is based on the micrometer. For user production deployment, we also need to provide a feasible and sufficiently detailed solution for reporting to zipkin or wavefront through OTEL.

Micrometer Observation can work with Micrometer Tracing. Micrometer Tracing is an abstraction over tracing that can use OTEL as a bridge. There's nothing you need to change really to make this work with OTel 🤷 BTW you can find this here https://github.com/apache/dubbo/pull/11021/files#diff-dfd2e12c668d7d1cb35baf3117d32272b38a03e0bec26dbd21a324098d90783dR138-R145

@AlbumenJ
Copy link
Member

image
Some test cases need to be fixed.

@AlbumenJ
Copy link
Member

Actually the whole setup is done manually only because you're not using Boot 3. In Boot 3 all of that is auto-configured.

I have created some spring boot 3 related samples[1] for Dubbo last month. Do you mean that in these samples everything will work fine without any configuration?

[1] https://github.com/apache/dubbo-samples/tree/master/10-task

Micrometer Observation can work with Micrometer Tracing. Micrometer Tracing is an abstraction over tracing that can use OTEL as a bridge. There's nothing you need to change really to make this work with OTel 🤷 BTW you can find this here https://github.com/apache/dubbo/pull/11021/files#diff-dfd2e12c668d7d1cb35baf3117d32272b38a03e0bec26dbd21a324098d90783dR138-R145

Are you willing to submit relevant demos and documents about this function? It is still very difficult for users who are not familiar with us to use it. 🤯

@marcingrzejszczak
Copy link
Contributor Author

Fixed the broken test, sorry about that

@marcingrzejszczak
Copy link
Contributor Author

I have created some spring boot 3 related samples[1] for Dubbo last month. Do you mean that in these samples everything will work fine without any configuration?

If you add the dependencies as presented here then yes, you don't need to pass any configuration. Check this doc https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#actuator.micrometer-tracing and https://micrometer.io/docs/tracing

Are you willing to submit relevant demos and documents about this function? It is still very difficult for users who are not familiar with us to use it. exploding_head

Sure, how can I help?

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 14 Code Smells

42.8% 42.8% Coverage
23.2% 23.2% Duplication

@AlbumenJ AlbumenJ merged commit b456d23 into apache:3.2 Jan 25, 2023
@marcingrzejszczak
Copy link
Contributor Author

marcingrzejszczak commented Jan 26, 2023

there you go apache/dubbo-website#1954

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.

Micrometer Observation Support
6 participants