Skip to content

Service/Application Dependency Graph Implement#1460

Open
ambiguous-pointer wants to merge 11 commits intoapache:developfrom
sohandsomejie:develop
Open

Service/Application Dependency Graph Implement#1460
ambiguous-pointer wants to merge 11 commits intoapache:developfrom
sohandsomejie:develop

Conversation

@ambiguous-pointer
Copy link
Copy Markdown

This change introduces a complete service and application topology visualization feature based on
discussion #1398 and
issue #1430.

It adds both backend graph APIs and frontend AntV G6 visualization for tracing upstream/downstream
relationships via ServiceProviderMetadataResource and ServiceConsumerMetadataResource.


📌 What’s New

  • Application-level topology graph
    GET /application/graph returns provider/consumer application relations as typed nodes
    and edges. Each node declares its type (application) and rule (provider/consumer/empty).

  • Service-level topology graph
    GET /service/graph returns provider/consumer applications for a given service as a graph.
    A central service node is connected to provider and consumer app nodes.

  • Service detail API
    GET /service/detail returns aggregated service metadata (language, method names) derived
    from all provider instances sharing the same serviceKey.

  • Service resource derivation
    ServiceProviderMetadataEventSubscriber now maintains Service resources by aggregating
    methods from all provider instances. Language is auto-detected from provider metadata
    parameters and method type signatures (golang/java).

  • Graph payload structure

    {
        "code": "Success",
        "message": "success",
        "data": {
            "nodes": [
                {
                    "id": "order-service",
                    "label": "order-service",
                    "type": "application",
                    "rule": "provider"
                },
                {
                    "id": "com.ecommerce.api.service.OrderService::",
                    "label": "com.ecommerce.api.service.OrderService::",
                    "type": "service",
                    "rule": ""
                },
                {
                    "id": "payment-service",
                    "label": "payment-service",
                    "type": "application",
                    "rule": "consumer"
                }
            ],
            "edges": [
                {
                    "source": "com.ecommerce.api.service.OrderService::",
                    "target": "order-service",
                    "data": { "type": "provides" }
                },
                {
                    "source": "payment-service",
                    "target": "com.ecommerce.api.service.OrderService::",
                    "data": { "type": "consumes" }
                }
            ]
        }
    }
    
  • Frontend topology visualization
    New Topology tab components for both Applications and Services pages, rendered using AntV G6
    with Vue-node integration. Clicking a node opens a detail drawer.
  • New indexes for efficient queries
    • idx_service_consumer_service_key on ServiceConsumerMetadataKind
    • idx_service_name on ServiceKind
  • Service proto simplification
    Service.{providers,consumers,features} replaced with a single methods []string field,
    derived by aggregating method names from all provider instances.

📁 Affected Areas / Review Checklist

  • Console API (service package handlers)
  • User Experience (graph visualization output)
  • Core Component (discovery subscriber, indexers)
  • Docs
  • Dubboctl
  • Feature

sohandsomejie and others added 6 commits April 16, 2026 20:20
…sion apache#1398

* feat(api): add GraphServices endpoint for service-level topology

Based on discussion apache#1398, use ServiceProviderMetadata and ServiceConsumerMetadata
to return provider/consumer application relations as graph nodes and edges for AntV G6.

* feat(api): add GraphApplications endpoint for application-level topology

Traverse provider/consumer service relations to build application-level graph.
Also add idx_service_consumer_service_key index to support efficient serviceKey queries.

* feat(api): add graph models (GraphNode, GraphEdge, GraphData) in pkg/console/model/graph.go

* feat(api): add ApplicationGraphReq, ServiceGraphReq and GetApplicationGraph, GetServiceGraph handlers

* feat(router): register /application/graph and /service/graph routes

* feat(api): fix error handling to use direct err pass-through instead of MeshNotFoundError
…he#1430](apache#1430))

* feat(api): replace Service.{providers,consumers,features} with {methods} field

Simplify Service proto by removing providers, consumers, and features map,
keeping only the aggregated methods list derived from provider metadata.

* feat(api): derive Service resource from ServiceProviderMetadata on add/update/delete

ServiceProviderMetadataEventSubscriber now maintains Service resources by
aggregating methods from all provider instances sharing the same serviceKey.
Handles add, update, and delete events to keep Service spec in sync.

* feat(api): add language detection from provider metadata parameters

Detect provider language (golang/java) from metadata parameters and method
type signatures when explicit language field is absent.

* feat(api): add GetServiceDetail endpoint returning language and methods

Add GET /service/detail returning ServiceDetailResp with language and
aggregated method names from the derived Service resource.

* feat(api): add BuildServiceIdentityKey helper for {service}:{version}:{group}

* feat(api): add ByServiceName index for ServiceKind

* feat(api): refactor SearchServices to query ServiceResource directly

SearchServices and SearchServicesByKeywords now use ServiceResource instead
of ServiceProviderMetadataResource for service listing.

* feat(api): remove providerAppName from ServiceSearchResp and ServiceTabDistributionReq

* feat(api): add ServiceDetailReq and ServiceDetailResp models

* feat(router): register /service/detail and /service/interfaces routes

* feat(ui-vue3): remove providerAppName from grafana types and tab components
Copy link
Copy Markdown
Contributor

@robocanic robocanic left a comment

Choose a reason for hiding this comment

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

Greatwork! I left some comments and hope you can improve based on the comments

Comment thread pkg/console/service/application.go Outdated
// SearchServicesByKeywords search services by keywords with prefix matching
func SearchServicesByKeywords(ctx consolectx.Context, req *model.ServiceSearchReq) (*model.SearchPaginationResult, error) {
pageData, err := manager.PageListByIndexes[*meshresource.ServiceProviderMetadataResource](
pageData, err := manager.PageListByIndexes[*meshresource.ServiceResource](
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Correction: 泛型里面用的是ServiceResource, 下面resourceKind传的却是ServiceProviderMetadataKind

return err
}

if oldRes != nil && oldRes.Spec != nil {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Correction:这里oldResource和newResource的key肯定是一样的,这个判断是多余的,processUpdate和processUpsert逻辑应该是一样的,需要去掉

serviceKey := meshresource.BuildServiceIdentityKey(serviceName, version, group)
resources, err := s.providerStore.ListByIndexes(
[]index.IndexCondition{{IndexName: index.ByMeshIndex, Value: mesh, Operator: index.Equals},
{IndexName: index.ByServiceProviderServiceName, Value: serviceName, Operator: index.Equals},
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggestion: 这里可以直接用ServiceKey的索引,可以去掉后面的version和group的判断

"github.com/duke-git/lancet/v2/strutil"
"k8s.io/client-go/tools/cache"

meshproto "github.com/apache/dubbo-admin/api/mesh/v1alpha1"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggestion:可以多写写注释

sohandsomejie and others added 5 commits April 19, 2026 12:29
* chore: translate Chinese comment to English in GraphApplications error handling
* chore: reorder imports in service_provider_metadata.go
…a sync

  1. pkg/console/service/service.go:132
     - fix generic type mismatch with resourceKind
     - generic ServiceResource should use ServiceKind, was incorrectly passing ServiceProviderMetadataKind
     - index changed from ByServiceProviderServiceName to ByServiceName (aligned with ServiceKind)

  2. pkg/core/discovery/subscriber/service_provider_metadata.go
     - processUpdate: remove redundant oldRes key check (oldKey always equals newKey in same resource update,
       else branch is unreachable dead code)
     - syncService: use ByServiceProviderServiceKey index instead of ByServiceProviderServiceName
       + manual version/group filtering, reduces data returned from DB and improves performance
       Ref: [1460](apache#1460 (comment))
@sonarqubecloud
Copy link
Copy Markdown

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