通过在你的API中添加一个相关的ID来轻松地调查问题

With APIs becoming more complex and distributed, developers sometimes struggle to find the relevant logs when they need to investigate a specific issue. In the new Salesforce Commerce APIs (SCAPI), we created such an architecture of distributed systems and recognized this problem early. Our approach to mitigate it was the introduction of a correlation ID.

随着API变得越来越复杂和分布式,开发人员在需要调查某个特定问题时,有时很难找到相关的日志。在新的Salesforce Commerce APIs(SCAPI)中,我们创建了这样一个分布式系统的架构,并及早认识到了这个问题。我们缓解它的方法是引入了一个相关的ID。

This ID is a unique identifier of the API request across systems and is commonly used for these scenarios. It has proven to be very helpful for internal developers as well as external users.

这个ID是跨系统的API请求的唯一标识,通常用于这些场景。事实证明,它对内部开发人员和外部用户都很有帮助。

This blog post describes how a correlation ID can be leveraged to easily find logs for further investigation.

这篇博文描述了如何利用相关的ID来轻松找到日志以进行进一步调查。

A quick overview of the SCAPI ecosystem

对SCAPI生态系统的快速概述

In order to understand the necessity of a correlation ID, let’s have a look at the architecture in place.

为了理解相关性ID的必要性,让我们看一下现有的架构。

Diagram showing the architecture of the Salesforce Commerce API ecosystem

显示Salesforce Commerce API生态系统架构的图示

  1. Every HTTP request to these new REST APIs initially comes in through the CDN layer. Among other things, this layer is responsible for routing the request to the correct instance of the API layer.
  2. 对这些新的REST APIs的每一个HTTP请求最初都是通过CDN层进来的。在其他方面,该层负责将请求路由到API层的正确实例。
  3. The API layer (e.g. Mulesoft) acts as an API middleware or gateway with applications handling the API requests. During processing, a request is made to the Commerce Cloud backend.
  4. API层(如Mulesoft)作为一个API中间件或网关,由应用程序处理API请求。在处理过程中,向商务云后端发出请求。
  5. The Commerce Cloud backend consists of services that generate and return a response.
  6. 商务云后端由产生和返回响应的服务组成。

Each component has access to the monitoring layer where the log events are aggregated.

每个组件都可以访问监控层,在那里,日志事件被聚集起来。

The benefit of a correlation ID

关联ID的好处

When looking at the architecture diagram above, we can spot a few issues that a developer might face. The applica...

开通本站会员,查看完整译文。

首页 - Wiki
Copyright © 2011-2024 iteam. Current version is 2.124.0. UTC+08:00, 2024-05-02 19:38
浙ICP备14020137号-1 $访客地图$