← 返回
未分类 中文

Service Dependency Mapper

Auto-discover and map service dependencies from code, configs, and runtime data. Generate dependency graphs, identify critical paths, find single points of f...
自动发现代码、配置和运行时数据中的服务依赖,生成依赖图,识别关键路径和单点故障。
charlie-morrison charlie-morrison 来源
未分类 clawhub v1.0.0 1 版本 100000 Key: 无需
★ 0
Stars
📥 357
下载
💾 0
安装
1
版本
#latest

概述

Service Dependency Mapper

Map your service dependencies before an outage teaches you what they are. Auto-discover dependencies from code imports, config files, network traffic, and runtime traces — then generate dependency graphs, identify critical paths, and assess blast radius.

Use when: "map our services", "what depends on what", "service dependency graph", "blast radius analysis", "single point of failure", "what breaks if X goes down", "architecture visualization", or during incident planning.

Commands

1. discover — Auto-Detect Service Dependencies

Step 1: Static Analysis — Code and Config

# Find service URLs in code
rg "https?://[a-z][-a-z0-9]*(\.[a-z][-a-z0-9]*)*[:/]" \
  --type-not binary -g '!node_modules' -g '!vendor' -g '!*.test.*' 2>/dev/null | \
  grep -v "example\.com\|localhost\|127\.0\.\|schema\.org" | head -30

# Find service names in Docker Compose
rg "depends_on|links:|container_name:" docker-compose*.yml 2>/dev/null

# Find service references in Kubernetes
rg "serviceName:|host:|backend:" k8s/ manifests/ helm/ 2>/dev/null

# Find database/cache connections
rg "DATABASE_URL|REDIS_URL|MONGO_URI|POSTGRES_|MYSQL_|AMQP_URL|KAFKA_BROKER" \
  --type-not binary -g '!node_modules' -g '!vendor' 2>/dev/null

# Find message queue producers/consumers
rg "publish\(|subscribe\(|produce\(|consume\(|\.queue\(|channel\." \
  --type-not binary -g '!node_modules' -g '!vendor' 2>/dev/null | head -20

# Find gRPC/REST client instantiations
rg "GrpcClient|HttpClient|axios\.create|fetch\(.*service|\.NewClient" \
  --type-not binary -g '!node_modules' -g '!vendor' 2>/dev/null

Step 2: Runtime Analysis (if available)

# Kubernetes services
kubectl get services -A -o json | python3 -c "
import json, sys
svcs = json.load(sys.stdin)['items']
for svc in svcs:
    ns = svc['metadata']['namespace']
    name = svc['metadata']['name']
    stype = svc['spec']['type']
    ports = [str(p['port']) for p in svc['spec'].get('ports', [])]
    print(f'{ns}/{name} ({stype}) ports:{','.join(ports)}')
"

# Service mesh (Istio/Linkerd) — actual traffic dependencies
kubectl get destinationrules -A 2>/dev/null
istioctl proxy-config cluster <pod-name> 2>/dev/null | grep -v "BlackHole\|PassthroughCluster"

Step 3: Build Dependency Graph

dependencies = {
    'api-gateway': {
        'depends_on': ['auth-service', 'user-service', 'order-service'],
        'type': 'sync',  # sync HTTP calls
        'criticality': 'critical',
    },
    'order-service': {
        'depends_on': ['postgres', 'payment-service', 'kafka'],
        'type': 'mixed',
        'criticality': 'critical',
    },
    'notification-service': {
        'depends_on': ['kafka', 'smtp-relay', 'redis'],
        'type': 'async',
        'criticality': 'low',
    },
}

Step 4: Generate Dependency Map

# Service Dependency Map

## Graph (text representation)

[External Users]

[api-gateway] ─sync──► [auth-service] ─sync──► [postgres-auth]

│ │

│ ├─sync──► [user-service] ─sync──► [postgres-users]

│ │ └─async─► [redis-cache]

│ │

│ └─sync──► [order-service] ─sync──► [postgres-orders]

│ │ └─sync──► [payment-service] ─► [Stripe API]

│ │

│ └─async──► [kafka]

│ │

│ ├──► [notification-service] ─► [SMTP]

│ └──► [analytics-service] ─► [ClickHouse]


## Critical Path
api-gateway → order-service → postgres-orders
(Failure here = orders cannot be placed)

## Single Points of Failure
1. 🔴 **postgres-orders** — no replica, single instance
2. 🔴 **api-gateway** — single entry point, no fallback
3. 🟡 **kafka** — 3 brokers but no multi-AZ
4. 🟡 **Stripe API** — external dependency, no fallback payment provider

## Blast Radius Analysis
| If this fails... | These break... | Users affected |
|-------------------|---------------|----------------|
| postgres-orders | order-service, api-gateway (partial) | 100% orders |
| auth-service | All authenticated endpoints | 100% users |
| kafka | notifications, analytics | 0% (graceful degradation) |
| redis-cache | user-service (slow, not down) | 0% (cache miss only) |
| Stripe API | payment-service, orders | 100% new orders |

2. blast-radius — Analyze Impact of Service Failure

For a given service, trace all dependents (recursively):

  • Direct dependents (call this service)
  • Transitive dependents (depend on direct dependents)
  • User-facing impact (which user flows break?)
  • Graceful degradation (can dependents function without this service?)

3. visualize — Generate Diagram

Output dependency graph in:

  • Mermaid (for GitHub/GitLab markdown)
  • DOT (for Graphviz)
  • PlantUML
  • D2

4. health — Assess Architecture Health

Score the architecture based on:

  • Depth of dependency chain (deep chains = fragile)
  • Fan-out per service (wide fan-out = complex failure modes)
  • Circular dependencies (exist? how many?)
  • Single points of failure count
  • Ratio of sync vs async dependencies
  • External dependency count and fallback coverage

版本历史

共 1 个版本

  • v1.0.0 当前
    2026-05-08 02:06 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

it-ops-security

1password

steipete
设置和使用 1Password CLI (op)。适用于:安装 CLI、启用桌面应用集成、登录(单/多账户)、通过 op 读取/注入/运行密钥。
★ 53 📥 31,629
it-ops-security

OpenClaw Backup

alex3alex
备份与恢复 OpenClaw 数据。适用于创建备份、设置自动备份计划、从备份恢复或管理备份轮转。处理 ~/.openclaw 目录归档并包含适当的排除规则。
★ 90 📥 30,940
dev-programming

Devcontainer Validator

charlie-morrison
在 VS Code 开发容器中验证 devcontainer.json 的语法、结构、功能、端口、生命周期脚本、定制项及安全最佳实践。
★ 0 📥 518