【发布时间】:2020-11-29 20:18:20
【问题描述】:
我是分布式日志记录的新手,我需要有关跨 Http Request 和 Messaging Request 传播额外字段的帮助。 目前,我可以传播 traceId 和 spanId,但我需要传递 correlationId 才能在所有微服务中传播。
spring:
sleuth:
correlation-fields:
- x-correlation-id
remote-fields:
- x-correlation-id
logback.xml
%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(%5p [${appName},%X{traceId:-},%X{parentId:-},%X{spanId:-},%X{correlation-id:-}]) %clr(${PID:- }){magenta} %clr(---){faint} %clr([%t]){faint} %clr(%logger{20}:%line){cyan} %clr(:){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}
我有点好奇如何将关联 id 传递给其他服务。
In case the message starts from Service A -
Service A (Message Started,CorrelationID-123) -> ServiceB (CorrelationID-123) -> ServiceC(CorrelationID-123)
In case if it started with Service B
Service B (Message Started,CorrelationID-123) -> ServiceA (CorrelationID-123) -> ServiceC(CorrelationID-123)
- 如何将关联 ID 传递给 Kafka 消息?
- 关联 ID 将如何传递给 Http 请求?
- 是否可以使用来自其他服务的现有 tracedId?
【问题讨论】:
-
您使用术语correlationId,但我认为您可能还使用了foobarId。如果我可以简洁地说,问题是如何传播给定的密钥对,使其在下游保持一致和可访问,就像 traceId 或 spanId 是一致和可访问的一样。
标签: spring spring-cloud-sleuth zipkin