英文:
How to configure istio-proxy to log traceId?
问题
我正在使用 Istio 版本 1.3.5。是否有需要设置的配置以允许 istio-proxy 记录 traceId?我正在启用 Jaeger 追踪(使用 Zipkin 协议)。通过记录 traceId,我想实现以下目标之一:
- 在多个上游服务中进行日志相关性。基本上,我可以通过特定的 traceId 过滤所有日志。
英文:
I am using istio with version 1.3.5. Is there any configuration to be set to allow istio-proxy to log traceId? I am using jaeger tracing (wit zipkin protocol) being enabled. There is one thing I want to accomplish by having traceId logging:
- log correlation in multiple services upstream. Basically I can filter all logs by certain traceId.
答案1
得分: 1
根据Envoy代理文档,用于Istio 1.3的Envoy v1.12.0
版本:
跟踪上下文传播[](https://www.envoyproxy.io/docs/envoy/latest/intro/arch_overview/observability/tracing.html?highlight=traceid#trace-context-propagation "此标题的永久链接")
Envoy提供了报告有关网格中服务之间通信的跟踪信息的能力。但是,为了能够关联由调用流程中各个代理生成的跟踪信息的部分,服务必须在入站和出站请求之间传播某些跟踪上下文。
无论使用哪个跟踪提供程序,服务都应传播 x-request-id 以启用跨调用服务的日志记录能够关联。
跟踪提供程序还需要其他上下文,以便理解跨跨度(工作的逻辑单元)之间的父/子关系。这可以通过在服务内部直接使用LightStep(通过OpenTracing API)或Zipkin跟踪器来实现,从入站请求中提取跟踪上下文并将其注入到任何后续的出站请求中。这种方法还使服务能够创建附加的跨度,描述在服务内部执行的工作,在检查端到端跟踪时可能会有用。
或者,跟踪上下文也可以由服务手动传播:
当使用LightStep跟踪器时,Envoy依赖于服务传播 x-ot-span-context HTTP标头,同时向其他服务发送HTTP请求。
当使用Zipkin跟踪器时,Envoy依赖于服务传播B3 HTTP标头( x-b3-traceid, x-b3-spanid, x-b3-parentspanid, x-b3-sampled以及 x-b3-flags)。 x-b3-sampled标头也可以由外部客户端提供,以启用或禁用特定请求的跟踪。此外,还支持单一 b3标头传播格式,这是一种更紧凑的格式。
当使用Datadog跟踪器时,Envoy依赖于服务传播Datadog特定的HTTP标头( x-datadog-trace-id, x-datadog-parent-id, x-datadog-sampling-priority)。
简而言之:需要手动添加traceId标头到B3 HTTP标头。
附加信息:https://github.com/openzipkin/b3-propagation
英文:
According to envoy proxy documentation for envoy v1.12.0
used by istio 1.3
:
>## Trace context propagation[](https://www.envoyproxy.io/docs/envoy/latest/intro/arch_overview/observability/tracing.html?highlight=traceid#trace-context-propagation "Permalink to this headline")
>
>Envoy provides the capability for reporting tracing information regarding communications between services in the mesh. However, to be able to correlate the pieces of tracing information generated by the various proxies within a call flow, the services must propagate certain trace context between the inbound and outbound requests.
>
>Whichever tracing provider is being used, the service should propagate the x-request-id to enable logging across the invoked services to be correlated.
>
>The tracing providers also require additional context, to enable the parent/child relationships between the spans (logical units of work) to be understood. This can be achieved by using the LightStep (via OpenTracing API) or Zipkin tracer directly within the service itself, to extract the trace context from the inbound request and inject it into any subsequent outbound requests. This approach would also enable the service to create additional spans, describing work being done internally within the service, that may be useful when examining the end-to-end trace.
>
>Alternatively the trace context can be manually propagated by the service:
>
> - When using the LightStep tracer, Envoy relies on the service to propagate the
> x-ot-span-context
> HTTP header while sending HTTP requests to other services.
>
> - When using the Zipkin tracer, Envoy relies on the service to propagate the B3 HTTP headers (
> x-b3-traceid,
> x-b3-spanid,
> x-b3-parentspanid,
> x-b3-sampled,
> and
> x-b3-flags).
> The
> x-b3-sampled
> header can also be supplied by an external client to either enable or
> disable tracing for a particular request. In addition, the single
> b3
> header propagation format is supported, which is a more compressed
> format.
>
> - When using the Datadog tracer, Envoy relies on the service to propagate the Datadog-specific HTTP headers (
> x-datadog-trace-id,
> x-datadog-parent-id,
> x-datadog-sampling-priority).
TLDR: traceId headers need to be manually added to B3 HTTP headers.
Additional information: https://github.com/openzipkin/b3-propagation
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论