|
| 1 | +--- |
| 2 | +title: 上下文传播 |
| 3 | +weight: 10 |
| 4 | +description: 了解实现分布式追踪的概念。 |
| 5 | +--- |
| 6 | + |
| 7 | +<!-- |
| 8 | +--- |
| 9 | +title: Context Propagation |
| 10 | +weight: 10 |
| 11 | +description: Learn about the concept that enables Distributed Tracing. |
| 12 | +--- |
| 13 | +--> |
| 14 | + |
| 15 | +<!-- |
| 16 | +With Context Propagation, [Signals](/docs/concepts/signals) can be correlated |
| 17 | +with each other, regardless of where they are generated. Although not limited to |
| 18 | +tracing, it is what allows [traces](/docs/concepts/signals/traces) to build |
| 19 | +causal information about a system across services that are arbitrarily |
| 20 | +distributed across process and network boundaries. |
| 21 | +--> |
| 22 | +通过上下文传播,[信号](/docs/concepts/signals)可以相互关联, |
| 23 | +无论它们是在何处生成的。 |
| 24 | +尽管它不仅限于链路追踪,但它允许 [trace](/docs/concepts/signals/traces) |
| 25 | +跨进程和网络边界任意分布的服务构建相关系统的关联信息。 |
| 26 | + |
| 27 | +<!-- |
| 28 | +We define Context Propagation by two sub-concepts: Context and Propagation. |
| 29 | +--> |
| 30 | +我们通过两个子概念来定义上下文传播:上下文和传播。 |
| 31 | + |
| 32 | +<!-- |
| 33 | +## Context |
| 34 | +
|
| 35 | +A **Context** is an object that contains the information for the sending and |
| 36 | +receiving service (or |
| 37 | +[execution unit](/docs/specs/otel/glossary/#execution-unit)) to correlate one |
| 38 | +signal with another. |
| 39 | +--> |
| 40 | +## 上下文 |
| 41 | + |
| 42 | +**上下文**是一个对象,它包含发送和接收服务 |
| 43 | +(或[执行单元](/docs/specs/otel/glossary/#execution-unit)) |
| 44 | +用于将一个信号与另一个信号关联起来的信息。 |
| 45 | + |
| 46 | +<!-- |
| 47 | +For example, if Service A calls Service B, then a span from Service A whose ID |
| 48 | +is in context will be used as the parent span for the next span created in |
| 49 | +Service B. The trace ID that is in context will be used for the next span |
| 50 | +created in Service B as well, which signifies that the span is part of the same |
| 51 | +trace as the span from Service A. |
| 52 | +--> |
| 53 | +例如,如果服务 A 调用服务 B,那么服务 A 中 ID 在上下文中的 span 将用作服务 |
| 54 | +B 中创建的下一个 span 的父 span。 |
| 55 | +上下文中的 trace ID 也将用于服务 B 中创建的下一个 span, |
| 56 | +这表示该 span 与服务 A 中的 span 属于同一 trace 的一部分。 |
| 57 | + |
| 58 | +<!-- |
| 59 | +## Propagation |
| 60 | +
|
| 61 | +**Propagation** is the mechanism that moves context between services and |
| 62 | +processes. It serializes or deserializes the context object and provides the |
| 63 | +relevant information to be propagated from one service to another. Propagation |
| 64 | +is usually handled by instrumentation libraries and is transparent to the user, |
| 65 | +but in the event that you need to manually propagate context, you can use |
| 66 | +Propagation APIs. |
| 67 | +--> |
| 68 | +## 传播 |
| 69 | + |
| 70 | +**传播**是上下文在服务和进程之间移动的机制。 |
| 71 | +它序列化或反序列化上下文对象并提供要从一个服务传播到另一个服务的相关信息。 |
| 72 | +传播通常由检测库处理并且对用户是透明的,但如果你需要手动传播上下文,则可以使用传播 API。 |
| 73 | + |
| 74 | +<!-- |
| 75 | +OpenTelemetry maintains several official propagators. The default propagator is |
| 76 | +using the headers specified by the |
| 77 | +[W3C TraceContext](https://www.w3.org/TR/trace-context/) specification. |
| 78 | +--> |
| 79 | +OpenTelemetry 维护着几个官方传播器。 |
| 80 | +默认传播器使用 [W3C 追踪上下文](https://www.w3.org/TR/trace-context/) |
| 81 | +规范指定的标头。 |
| 82 | + |
| 83 | +<!-- |
| 84 | +## Specification |
| 85 | +
|
| 86 | +To learn more about Context Propagation, see the |
| 87 | +[Context specification](/docs/specs/otel/context/). |
| 88 | +--> |
| 89 | +## 规范 |
| 90 | + |
| 91 | +要了解有关上下文传播的更多信息,请参阅[上下文规范](/docs/specs/otel/context/)。 |
0 commit comments