Documentation ¶
Index ¶
Constants ¶
const ( // KeyTrace : 寫入ctx locals 的 key KeyTrace = "Trace" // KeySpanID : 寫入ctx locals 的 key KeySpanID = "SpanID" // KeyTraceTrue : 寫入ctx local s的 key KeyTraceTrue = "TraceTrue" )
const XCloudTraceContext = "X-Cloud-Trace-Context"
XCloudTraceContext : https://cloud.google.com/trace/docs/setup
Variables ¶
var ConfigDefault = Config{ TraceHaderKey: XCloudTraceContext, AllResAddTraceID: false, }
Functions ¶
func GetTraceKey ¶
func GetTraceKey() string
Types ¶
type SpanID ¶
type SpanID = string
SpanID : is the decimal representation of the (unsigned) span ID. It should be randomly generated and unique in your trace. For subsequent requests, set SPAN_ID to the span ID of the parent request. See the description of TraceSpan (REST, RPC) for more information about nested traces.
type Trace ¶
type Trace struct { TraceID TraceID `json:"TraceID"` SpanID SpanID `json:"SpanID"` TraceTrue TraceTrue `json:"TraceTrue"` Raw string `json:"raw"` }
Trace : https://cloud.google.com/trace/docs/setup
func Conv ¶
Conv : 從 header 上的 X-Cloud-Trace-Context 取值
curl "http://www.example.com" --header "X-Cloud-Trace-Context: 105445aa7843bc8bf206b12000100000/1;o=1"
func (Trace) Conv ¶
Conv : 將 GoogleCloudTrace 轉為string結構
"X-Cloud-Trace-Context: TRACE_ID/SPAN_ID;o=TRACE_TRUE"
func (Trace) FastHTTPHeader ¶
FastHTTPHeader : 設定 fasthttp 發出的 header
func (Trace) HTTPHeader ¶
HTTPHeader : 設定 http 發出的 header
type TraceID ¶
type TraceID = string
TraceID : is a 32-character hexadecimal value representing a 128-bit number. It should be unique between your requests, unless you intentionally want to bundle the requests together. You can use UUIDs.
type TraceTrue ¶
type TraceTrue = bool
TraceTrue : must be 1 to trace this request. Specify 0 to not trace the request.
Cloud Trace doesn't sample every request. For example, if you use Java and OpenCensus, then only 1 request out of every 10,000 is traced. If you are using App Engine, requests are sampled at a rate of 0.1 requests per second for each App Engine instance. If you use the Cloud Trace API, then you can configure customer rates. Some packages, such as the Java OpenCensus package, support configuring the sampling rate.