W3Cschool
恭喜您成為首批注冊用戶
獲得88經(jīng)驗值獎勵
您可以使用Tracer
手動創(chuàng)建spans,如以下示例所示:
// Start a span. If there was a span present in this thread it will become // the `newSpan`'s parent. Span newSpan = this.tracer.nextSpan().name("calculateTax"); try (Tracer.SpanInScope ws = this.tracer.withSpanInScope(newSpan.start())) { // ... // You can tag a span newSpan.tag("taxValue", taxValue); // ... // You can log an event on a span newSpan.annotate("taxCalculated"); } finally { // Once done remember to finish the span. This will allow collecting // the span to send it to Zipkin newSpan.finish(); }
在前面的示例中,我們可以看到如何創(chuàng)建跨度的新實例。如果此線程中已經(jīng)有一個跨度,它將成為新跨度的父級。
創(chuàng)建跨度后,請始終保持清潔。另外,請務(wù)必完成要發(fā)送到Zipkin的所有跨度。
如果您的跨度包含的名稱大于50個字符,則該名稱將被截斷為50個字符。您的名字必須明確明確。知名人士會導(dǎo)致延遲問題,有時甚至?xí)l(fā)例外情況。
Copyright©2021 w3cschool編程獅|閩ICP備15016281號-3|閩公網(wǎng)安備35020302033924號
違法和不良信息舉報電話:173-0602-2364|舉報郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號
聯(lián)系方式:
更多建議: