如何配置istio-proxy以记录traceId?

huangapple go评论68阅读模式
英文:

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跟踪器来实现,从入站请求中提取跟踪上下文并将其注入到任何后续的出站请求中。这种方法还使服务能够创建附加的跨度,描述在服务内部执行的工作,在检查端到端跟踪时可能会有用。

或者,跟踪上下文也可以由服务手动传播:

简而言之:需要手动添加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

huangapple
  • 本文由 发表于 2020年1月3日 15:43:41
  • 转载请务必保留本文链接:https://go.coder-hub.com/59574885.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定