Network requests and traces
The SDK reports the HTTP requests your channel makes, and can carry a trace header into your own backends so their traces join the RUM session. This page covers both, and how to keep chosen URLs out of the data.
Network requests
Use CxUrlTransfer instead of roUrlTransfer in the Task that makes your
requests. Its methods are the same, and the SDK reports every request with its
method, URL, status code, duration and size.
Don't callfunc from the render thread into the Task that makes requests
while a request is in flight. Each side waits for the other and the channel
hangs.
-
Load it in the Task. A component can only call functions from scripts it loads itself, so this step is required. In the Task's XML:
<script type="text/brightscript" uri="pkg:/source/roku_modules/coralogix_roku/instrumentations/network/CxUrlTransfer.brs" />Or, if the Task's code is in a BrighterScript (
.bs) file, import it there:import "pkg:/source/roku_modules/coralogix_roku/instrumentations/network/CxUrlTransfer.brs" -
Create it where you created
roUrlTransfer:ut = coralogix_roku_CxUrlTransfer(m.global)ut.SetUrl("https://api.example.com/catalog")body = ut.GetToString() -
For async requests, pass each
roUrlEventtoReportEvent:ut.SetMessagePort(port)ut.AsyncGetToString()msg = wait(0, port)if type(msg) = "roUrlEvent"ut.ReportEvent(msg)end if
To report a request made another way, call reportNetworkRequest:
m.global.cxRum.callfunc("reportNetworkRequest", {
method: "GET", url: "https://api.example.com/catalog", statusCode: 200, durationMs: 184
})
Optional fields: startTime (epoch ms), failureReason and
responseContentLength (bytes).
Ignore URLs
ignoreUrls drops network requests whose URL matches. A string must equal the
URL; a regular expression is written between slashes, with the flags i, m,
s and x. Set it in
coralogix_roku_initialize(), as with every
option:
coralogix_roku_initialize({
' ...
ignoreUrls: [
"https://api.example.com/health", ' this exact URL
"/^https:\/\/analytics\.example\.com\//" ' any URL on this host
]
}, screen.getGlobalNode())
Traces
Add a W3C traceparent header to requests to your backends, so their traces
join the RUM session. allowedTracingUrls takes strings and regular
expressions, matched the same way as ignoreUrls:
coralogix_roku_initialize({
' ...
traceParentInHeader: {
enabled: true,
options: { allowedTracingUrls: ["/^https:\/\/api\.example\.com\//"] }
}
}, screen.getGlobalNode())
The SDK adds the header to requests made with CxUrlTransfer. Without
allowedTracingUrls, every such request gets it, including third parties, except
URLs in ignoreUrls. If you set traceparent or tracestate yourself, the SDK
leaves your headers as they are.