Context Propagation in opentelemetry-go-auto-instrumentation
is inspired
by Apache-Skywalking.
Context in OpenTelemetry is a design for propagating trace-related information in distributed systems. Based on the
propagation of Context, distributed services (AKA Spans) can be linked together to form a complete call chain (AKA
Trace). OpenTelemetry saves trace-related information in Golang's context.Context and requires users to correctly pass
context.Context. If context.Context is not passed correctly in the call chain, the call chain will be broken. To solve
this problem, when opentelemetry-go-auto-instrumentation
create a span, opentelemetry-go-auto-instrumentation
save
it to Golang's coroutine structure (i.e. GLS), and when opentelemetry-go-auto-instrumentation
create a new
coroutine, opentelemetry-go-auto-instrumentation
also copy the corresponding data structure from the current
coroutine. When opentelemetry-go-auto-instrumentation
need to create a new span
later, opentelemetry-go-auto-instrumentation
will query the most recently created span from GLS as the parent, so that
opentelemetry-go-auto-instrumentation
have the opportunity to protect
the integrity of the call chain.
Baggage is a data structure in OpenTelemetry used to share key-value pairs in Trace. Baggage is stored in
context.Context and is propagated along with the context.Context. If context.Context is not correctly propagated in the
call chain, subsequent services will not be able to read Baggage. To solve this problem,
when opentelemetry-go-auto-instrumentation
save the baggage to
context.Context, opentelemetry-go-auto-instrumentation
also save it to GLS. When context.Context is not passed
correctly, opentelemetry-go-auto-instrumentation
try to read the baggage from
GLS, which allows the baggage to be read in this case.
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。