Skip to content

[GSoC 2025] Add discovery-timeline QoS command to display real-time service discovery metadata #15590

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

Open
wants to merge 13 commits into
base: 3.3
Choose a base branch
from

Conversation

ankitshokeen
Copy link
Contributor

@ankitshokeen ankitshokeen commented Jul 27, 2025

Issue
#15212

Description

introduces a new command to the Dubbo QoS module: discovery-timeline. This command improves transparency into the service discovery process by listing active provider services along with their last known metadata update times and registry sources. It is designed to help developers and operators quickly inspect the current discovery state without diving deep into logs or complex diagnostics.

Benefits

  1. Providing a clear overview of all discovered services
  2. Displaying when each service was last reported via metadata
  3. Showing which registries are active and when they last refreshed
  4. Diagnosing service visibility or registration issues
  5. Monitoring refresh delays from registry sources
  6. Validating service registration during application startup or scaling events

Command Overview

Command: discovery-timeline

Used Examples: discovery-timeline discovery-timeline service=DemoService discovery-timeline registry=zookeeper://localhost:2181 discovery-timeline page=2 limit=5
Output Example

Discovery Timeline
------------------------------------------------------------
Registry                      |Last Refresh
------------------------------------------------------------
127.0.0.1:2181                |Mon Jul 28 01:15:12 IST 2025
------------------------------------------------------------
Provider Services
Discovered: org.apache.dubbo.DemoService        |Mon Jul 28 01:15:12 IST 2025
Discovered: org.apache.dubbo.MetadataService    |Mon Jul 28 01:15:12 IST 2025
------------------------------------------------------------

Tests Included

Verified On

$ telnet 127.0.0.1 22222
dubbo> discovery-timeline

@ankitshokeen
Copy link
Contributor Author

please take a look @AlbumenJ @songxiaosheng

@ankitshokeen ankitshokeen force-pushed the feature/discovery-timeline branch from f6b621d to 67ddb33 Compare July 27, 2025 21:32
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-parent</artifactId>
<version>${revision}</version>
<version>3.3.6-SNAPSHOT</version>
Copy link
Contributor

Choose a reason for hiding this comment

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

use revision

@@ -34,6 +34,18 @@
<skip_maven_deploy>false</skip_maven_deploy>
</properties>

<dependencyManagement>
Copy link
Contributor

@RainYuY RainYuY Jul 28, 2025

Choose a reason for hiding this comment

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

You don't need to import it because it's already managed by the parent dependencyManagement.

@RainYuY
Copy link
Contributor

RainYuY commented Jul 28, 2025

use spotless format your code

<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.10.3</version>
Copy link
Contributor

Choose a reason for hiding this comment

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

All versions should be defined in dependencyManagement.

@zrlw zrlw requested a review from RainYuY July 28, 2025 02:14
<scope>test</scope>
</dependency>
</dependencies>

<build>
Copy link
Contributor

@zrlw zrlw Jul 28, 2025

Choose a reason for hiding this comment

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

Delete it because building configuration should be managed by dubbo-parent for building dubbo with different jdk versions.

@@ -89,7 +100,89 @@
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<version>2.24.3</version>
Copy link
Contributor

Choose a reason for hiding this comment

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

Delete all your added dependencies because these artifacts have already been added for testing.

@zrlw
Copy link
Contributor

zrlw commented Jul 28, 2025

  1. should not configure artifacts for testing because dubbo-dependencies-bom has defined all artifacts dependencies for testing purpose.
  2. should not configure building configuration at module because it should be set at dubbo-parent pom.xml to support building dubbo with different jdk versions.
  3. should use jdk21+ to build or test your PR, including run mvn spotless:apply to meet Dubbo code format requirements.

@ankitshokeen ankitshokeen requested a review from zrlw July 28, 2025 20:18
@codecov-commenter
Copy link

codecov-commenter commented Jul 28, 2025

Codecov Report

❌ Patch coverage is 63.86139% with 73 lines in your changes missing coverage. Please review.
✅ Project coverage is 61.05%. Comparing base (ed65284) to head (04b7a9a).
⚠️ Report is 1 commits behind head on 3.3.

Files with missing lines Patch % Lines
...bbo/qos/command/impl/DiscoveryTimelineCommand.java 63.86% 56 Missing and 17 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##                3.3   #15590      +/-   ##
============================================
+ Coverage     61.02%   61.05%   +0.03%     
- Complexity    11500    11692     +192     
============================================
  Files          1909     1910       +1     
  Lines         86782    86984     +202     
  Branches      13094    13134      +40     
============================================
+ Hits          52961    53111     +150     
- Misses        28409    28441      +32     
- Partials       5412     5432      +20     
Flag Coverage Δ
integration-tests-java21 32.93% <1.49%> (-0.13%) ⬇️
integration-tests-java8 32.99% <1.49%> (-0.12%) ⬇️
samples-tests-java21 32.65% <1.49%> (+0.97%) ⬆️
samples-tests-java8 30.24% <1.49%> (+0.92%) ⬆️
unit-tests-java11 59.07% <63.68%> (-0.02%) ⬇️
unit-tests-java17 58.80% <63.68%> (+0.01%) ⬆️
unit-tests-java21 58.80% <63.68%> (+0.04%) ⬆️
unit-tests-java8 59.08% <63.86%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ankitshokeen
Copy link
Contributor Author

Please take a look @RainYuY @zrlw

@RainYuY
Copy link
Contributor

RainYuY commented Jul 29, 2025

Please take a look @RainYuY @zrlw

Please take a look at the reason for the action failure.
One of the issues is that you didn’t add a license header.

ERROR: The following files don't have a valid license header:
dubbo-plugin/dubbo-qos/META-INF/dubbo/internal/org.apache.dubbo.qos.api.BaseCommand

@@ -0,0 +1,42 @@
online=org.apache.dubbo.qos.command.impl.Online
Copy link
Contributor

Choose a reason for hiding this comment

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

Delete this file because it has already existed in resources


RegistryManager registryManager = applicationModel.getBeanFactory().getBean(RegistryManager.class);
if (registryManager == null) {
logger.warn("RegistryManager not available");
Copy link
Contributor

@zrlw zrlw Jul 29, 2025

Choose a reason for hiding this comment

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

All warning or error log info should logged by ErrorTypeAwareLogger. e.g.,

  1. has exception
    logger.warn(INTERNAL_ERROR, "some cause info", "", e.getMessage(), e);
  2. no exception
    logger.warn(INTERNAL_ERROR, "", "", "warning messages");
    INTERNAL_ERROR should be selected from LoggerCodeConstants.

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 by using ErrorTypeAwareLogger

@@ -88,6 +88,11 @@
<artifactId>log4j-slf4j-impl</artifactId>
<scope>test</scope>
</dependency>
<dependency>
Copy link
Contributor

@zrlw zrlw Jul 29, 2025

Choose a reason for hiding this comment

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

Delete it because it already existed in this pom. you'd better install Maven Helper plugin if you use Intellij IDEA to ensure what artifacts have been defined in the pom.

@zrlw
Copy link
Contributor

zrlw commented Jul 29, 2025

faebce44-1aed-4e6b-ab30-5425aae095c5

Dubbo has it's own logger.warn or logger.error codes requirements, you'd better search existed codes to find how to write them.

@zrlw zrlw self-requested a review July 29, 2025 07:37
@ankitshokeen
Copy link
Contributor Author

Please take a look @RainYuY @zrlw

Please take a look at the reason for the action failure. One of the issues is that you didn’t add a license header.

ERROR: The following files don't have a valid license header: dubbo-plugin/dubbo-qos/META-INF/dubbo/internal/org.apache.dubbo.qos.api.BaseCommand

added manually

@zrlw
Copy link
Contributor

zrlw commented Jul 30, 2025

ERROR: The following files don't have a valid license header: dubbo-plugin/dubbo-qos/META-INF/dubbo/internal/org.apache.dubbo.qos.api.BaseCommand

added manually

The cause is org.apache.dubbo.qos.api.BaseCommand should not be added to the wrong location dubbo-plugin/dubbo-qos/META-INF, all files that not existed in resources will be checked to ensure the license header was added.

Mockito.when(serviceInstance.getMetadata()).thenReturn(metadata);

String output = command.execute(new CommandContext("discovery-timeline"), null);
System.out.println("testExecuteWithTimestamps Output:\n" + output);
Copy link
Contributor

@zrlw zrlw Jul 30, 2025

Choose a reason for hiding this comment

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

Remove all System.out statements or log them refer to LsTest.java

@zrlw
Copy link
Contributor

zrlw commented Jul 30, 2025

Remove all System.out statements or log them refer to LsTest.java

@ankitshokeen
Copy link
Contributor Author

ERROR: The following files don't have a valid license header: dubbo-plugin/dubbo-qos/META-INF/dubbo/internal/org.apache.dubbo.qos.api.BaseCommand

added manually

The cause is org.apache.dubbo.qos.api.BaseCommand should not be added to the wrong location dubbo-plugin/dubbo-qos/META-INF, all files that not existed in resources will be checked to ensure the license header was added.

Screenshot From 2025-07-31 02-44-35 not in `dubbo-plugin/dubbo-qos/META-INF/dubbo/internal/` already placed at `dubbo-plugin/dubbo-qos/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.qos.api.BaseCommand` and still checking for licence header

@ankitshokeen ankitshokeen force-pushed the feature/discovery-timeline branch from b1f64dd to 6839f23 Compare July 30, 2025 21:28
@zrlw
Copy link
Contributor

zrlw commented Jul 31, 2025

not in dubbo-plugin/dubbo-qos/META-INF/dubbo/internal/ already placed at dubbo-plugin/dubbo-qos/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.qos.api.BaseCommand and still checking for licence header

  1. deleted dubbo-plugin/dubbo-qos/META-INF/dubbo/internal/org.apache.dubbo.qos.api.BaseCommand by b9bfc4c
  2. removed license header from dubbo-plugin/dubbo-qos/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.qos.api.BaseCommand by c4a89a1

see the result:
https://github.com/apache/dubbo/actions/runs/16639460109
7f8d1512-ff10-4591-91cd-15b1ef0fbff9

@zrlw
Copy link
Contributor

zrlw commented Jul 31, 2025

you'd better search some documents about how to solve git merge conflicts, force-merge should not be used if you are not familiar with the codes.
and the codes which are not related to the issue which you fixed should not be changed, you'd better check them in https://github.com/apache/dubbo/pull/15590/files or your local develope IDE.

@zrlw zrlw changed the title [Enhancement] Add discovery-timeline QoS command to display real-time service discovery metadata [GSoC 2025] Add discovery-timeline QoS command to display real-time service discovery metadata Jul 31, 2025
@zrlw zrlw requested a review from oxsean July 31, 2025 04:39
@RainYuY RainYuY requested a review from chickenlj July 31, 2025 05:28
@ankitshokeen
Copy link
Contributor Author

@zrlw do any further modifications are required for this PR?

@zrlw
Copy link
Contributor

zrlw commented Aug 2, 2025

@zrlw do any further modifications are required for this PR?

waiting for other reviewers checking.

@ankitshokeen
Copy link
Contributor Author

@zrlw do any further modifications are required for this PR?

waiting for other reviewers checking.

thanks for clarification.

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.

4 participants