Cloud Service Mesh 与 Service Directory 的集成为调试带来了新的复杂性。在您的企业中,服务使用方和服务提供方可能属于不同的团队或组织。为帮助您调试此类问题,Cloud Service Mesh 与 Cloud Logging 和 Cloud Monitoring 集成。
例如:
您有一项 checkout 服务使用 Cloud Service Mesh 提供应用网络。
而 Service Directory 中有一项 payment 服务是由另一个团队(服务提供方)拥有和维护的。
您希望从 checkout 服务调用 payment 服务,因此在 Cloud Service Mesh 中创建了一个新的后端服务。此后端服务使用 Service Directory 进行服务发现以连接到 payment 服务。
在此模型中,服务提供方可能需要删除或修改 Service Directory 中托管的 payment 服务。由于他们拥有 payment 服务,因此可以进行此类更改。但是,如果 payment 服务被删除,服务发现就会中断。
日志记录
当 Cloud Service Mesh 解析附加到 Service Directory 服务的后端服务时,它会从 Service Directory 中获取端点列表。如果服务已从 Service Directory 中删除,Cloud Service Mesh 将不会获取任何端点。在这种情况下,系统会将一则日志条目添加到 Logging。该日志条目包含以下信息:
后端服务名称
Service Directory 名称
一则消息:Service Directory returned 0 endpoints for this service.
此信息可帮助您调试相关问题。您还可以设置提醒以主动收到通知。
监控
与日志记录场景类似,Cloud Service Mesh 还与 Monitoring 集成以生成指标。Cloud Service Mesh 会将每个后端服务的以下指标添加到 Monitoring:
后端服务名称
与此 Cloud Service Mesh 客户端共享的后端服务关联的端点数
Cloud Service Mesh 客户端无法将流量发送到没有端点的后端服务。
Google Cloud 控制台
如果某个 Service Directory 服务已删除,但 Cloud Service Mesh 后端服务中存在与该服务的连接,则Google Cloud 控制台会显示一条警告:The attached
Service Directory service could not be found.
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-09-04。"],[],[],null,["# Observability and debugging with Service Directory\n==================================================\n\n|\n| **Preview**\n|\n|\n| This product or feature is subject to the \"Pre-GA Offerings Terms\" in the General Service Terms section\n| of the [Service Specific Terms](/terms/service-terms#1).\n|\n| Pre-GA products and features are available \"as is\" and might have limited support.\n|\n| For more information, see the\n| [launch stage descriptions](/products#product-launch-stages).\n\nCloud Service Mesh's integration with Service Directory introduces new\ncomplexities in debugging. Within your business, service consumers and\nservice producers might belong to different teams or organizations. To help you\ndebug such issues, Cloud Service Mesh integrates with Cloud Logging and\nCloud Monitoring.\n\nFor example:\n\n- You have a `checkout` service that uses Cloud Service Mesh for application networking.\n- There's a `payment` service in Service Directory that a different team (the *service producer*) owns and maintains.\n- You want to call on the `payment` service from the `checkout` service so you create a new backend service in Cloud Service Mesh. This backend service attaches to the `payment` service using Service Directory for service discovery.\n\nIn this model, the service producer might want to delete or modify the `payment`service that is hosted in Service Directory. Because they own\nthe `payment` service, they are permitted to make such changes. But if the\n`payment` service is deleted, service discovery is broken.\n| **Note:** This guide only supports Cloud Service Mesh with Google Cloud APIs and does not support Istio APIs. For more information see, [Cloud Service Mesh overview](/service-mesh/docs/overview).\n\nLogging\n-------\n\nWhen Cloud Service Mesh resolves a backend service that is attached to a\nService Directory service, it gets a list of endpoints from\nService Directory. If the service has been deleted from\nService Directory, Cloud Service Mesh doesn't get any endpoints.\nIn such a case, a log entry is added to Logging. The log entry\nincludes the following information:\n\n- The backend service name\n- The Service Directory name\n- A message: `Service Directory returned 0 endpoints for this service.`\n\nThis information helps you debug issues. You can also set up alerts to be\nproactively notified.\n\nMonitoring\n----------\n\nSimilar to the logging case, Cloud Service Mesh integrates with\nMonitoring to generate metrics. Cloud Service Mesh adds the\nfollowing metrics to Monitoring for each backend service:\n\n- The backend service name\n- The number of endpoints associated with this backend service that are shared with Cloud Service Mesh's clients\n\nCloud Service Mesh clients are not able to send traffic to backend services that\ndon't have endpoints.\n\nGoogle Cloud console\n--------------------\n\nIf a Service Directory service is deleted and an attachment to\nthat service exists in the Cloud Service Mesh backend service, the\nGoogle Cloud console displays a warning: `The attached\nService Directory service could not be found.`\n\nWhat's next\n-----------\n\n- Learn about [integrating Cloud Service Mesh with Service Directory](/service-mesh/v1.21/docs/service-routing/service-directory-integration).\n- Learn how to [set up the integration](/service-mesh/v1.21/docs/service-routing/service-directory-integration-setup).\n- Learn about [Service Directory observability](/service-directory/docs/monitoring)."]]