W3Cschool
恭喜您成為首批注冊用戶
獲得88經(jīng)驗(yàn)值獎(jiǎng)勵(lì)
有時(shí)您需要傳播額外的字段,例如請求ID或備用跟蹤上下文。例如,如果您處于Cloud Foundry環(huán)境中,則可能要傳遞請求ID,如以下示例所示:
// when you initialize the builder, define the extra field you want to propagate Tracing.newBuilder().propagationFactory( ExtraFieldPropagation.newFactory(B3Propagation.FACTORY, "x-vcap-request-id") ); // later, you can tag that request ID or use it in log correlation requestId = ExtraFieldPropagation.get("x-vcap-request-id");
您可能還需要傳播未使用的跟蹤上下文。例如,您可能處于Amazon Web服務(wù)環(huán)境中,但沒有向X-Ray報(bào)告數(shù)據(jù)。為了確保X射線可以正確共存,請傳遞其跟蹤標(biāo)頭,如以下示例所示:
tracingBuilder.propagationFactory( ExtraFieldPropagation.newFactory(B3Propagation.FACTORY, "x-amzn-trace-id") );
在Spring Cloud Sleuth中,跟蹤構(gòu)建器
Tracing.newBuilder()
的所有元素都定義為beans。因此,如果您要傳遞自定義PropagationFactory
,則足以創(chuàng)建該類型的bean,我們將在Tracing
bean中進(jìn)行設(shè)置。
Copyright©2021 w3cschool編程獅|閩ICP備15016281號-3|閩公網(wǎng)安備35020302033924號
違法和不良信息舉報(bào)電話:173-0602-2364|舉報(bào)郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號
聯(lián)系方式:
更多建議: