Trace Configuration¶
Trace Initialization Configuration¶
var tracer = uni.requireNativePlugin("GCUniPlugin-Tracer");
tracer.setConfig({
traceType: 'ddTrace'
});
| Parameter Name | Parameter Type | Required | 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 associate with RUM data, default false |
| enableNativeAutoTrace | boolean | No | Whether to enable native network auto-tracing. iOS supports NSURLSession, Android supports OKhttp, default false; Android cloud packaging is not supported. Since uni-app initiates network requests through system APIs on iOS, enabling this will automatically trace those requests. In this case, disable manual Trace collection on the iOS side to avoid incorrect association between the trace and RUM data |
Tracer Network Trace¶
Automatic Collection¶
After enabling gcResourceTracking in SDK 0.2.7 and above, standard uni.request will automatically append Propagation Headers that comply with the Trace configuration, without needing to replace the request method. For more information, refer to Resource Auto 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¶
Retrieves 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 type: object