Trace Configuration¶
Trace Initialization Configuration¶
var tracer = uni.requireNativePlugin("GCUniPlugin-Tracer");
tracer.setConfig({
traceType: 'ddTrace'
});
| Parameter Name | Parameter Type | Required | Parameter Description |
|---|---|---|---|
| samplerate | number | No | Sampling rate, range [0,1], default 1 |
| traceType | string | No | Trace type: ddTrace (default), zipkinMultiHeader, zipkinSingleHeader, traceparent, skywalking, jaeger |
| enableLinkRUMData | boolean | No | Whether to correlate with RUM data, default false |
| enableNativeAutoTrace | boolean | No | Whether to enable native network auto-tracing. iOS supports NSURLSession, Android supports OKhttp, default false. Not supported for Android cloud packaging. Since uni-app initiates network requests via system APIs on iOS, enabling this will automatically trace these requests. In this case, please disable manual Trace collection on the iOS side to avoid correlation errors between traces and RUM data. |
Tracer Network Trace¶
Automatic Collection¶
When a request is initiated via gcRequest.request, Propagation Headers are automatically appended. Please refer to Resource Collection in RUM Configuration.
Manual Collection¶
var tracer = uni.requireNativePlugin("GCUniPlugin-Tracer");
let key = Utils.getUUID();
var header = tracer.getTraceHeader({
key: key,
url: requestUrl
});
uni.request({
url: requestUrl,
header: header,
success() {
},
complete() {
}
});
API - getTraceHeader¶
Gets the Trace request header and adds it to the HTTP request header.
| Field | Type | Required | Description |
|---|---|---|---|
| key | string | Yes | Unique request identifier |
| url | string | Yes | Request URL |
Return value type: object