diff --git a/CHANGELOG.md b/CHANGELOG.md index f7196ac..128eb66 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,10 @@ # CHANGELOG All notable changes to this project will be documented in this file. +## [3.1.0] - 2022/09/01 +### Add + - Attribute `domain` to all HTTP events and metrics. + ## [3.0.2] - 2022/08/30 ### Fix - Harvest initial time, from 10 to 60 seconds. diff --git a/README.md b/README.md index e247b29..0d163aa 100644 --- a/README.md +++ b/README.md @@ -812,6 +812,7 @@ There is a set of attributes common to all actions sent over a `RokuSystem` and | `httpCode` | Response code. | `HTTP_COMPLETE`, `HTTP_CONNECT`, `HTTP_ERROR`, `HTTP_RESPONSE` | | `method` | HTTP method. | `HTTP_COMPLETE`, `HTTP_CONNECT`, `HTTP_ERROR`, `HTTP_REQUEST ` | | `origUrl` | Original URL of request. | `HTTP_COMPLETE`, `HTTP_CONNECT`, `HTTP_ERROR`, `HTTP_REQUEST`, `HTTP_RESPONSE` | +| `domain` | Host part of `origUrl`. | `HTTP_COMPLETE`, `HTTP_CONNECT`, `HTTP_ERROR`, `HTTP_REQUEST`, `HTTP_RESPONSE` | | `status` | Current request status. | `HTTP_COMPLETE`, `HTTP_CONNECT`, `HTTP_ERROR` | | `targetIp` | Target IP address of request. | `HTTP_COMPLETE`, `HTTP_CONNECT`, `HTTP_ERROR` | | `url` | Actual URL of request. | `HTTP_COMPLETE`, `HTTP_CONNECT`, `HTTP_ERROR` | @@ -938,6 +939,8 @@ The Roku agent generates the following metrics OOTB: Each metric is associated with an event generated by the agent. +All metrics include the attribute `domain`, that is the host of the HTTP request. + ### Ad Tracking diff --git a/components/NewRelicAgent/NRAgent.brs b/components/NewRelicAgent/NRAgent.brs index b3b6d7c..adc0f33 100644 --- a/components/NewRelicAgent/NRAgent.brs +++ b/components/NewRelicAgent/NRAgent.brs @@ -248,6 +248,7 @@ function nrSendVideoEvent(actionName as String, attr = invalid) as Void end function function nrSendHttpRequest(attr as Object) as Void + attr["domain"] = nrExtractDomainFromUrl(attr["origUrl"]) transId = stri(attr["transferIdentity"]) m.nrRequestIdentifiers[transId] = nrTimestamp() 'Clean up old transfers @@ -277,13 +278,14 @@ function nrSendHttpRequest(attr as Object) as Void end function function nrSendHttpResponse(attr as Object) as Void + attr["domain"] = nrExtractDomainFromUrl(attr["origUrl"]) transId = stri(attr["transferIdentity"]) if m.nrRequestIdentifiers[transId] <> invalid deltaMs = nrTimestamp() - m.nrRequestIdentifiers[transId] attr["timeSinceHttpRequest"] = deltaMs m.nrRequestIdentifiers.Delete(transId) 'Generate metrics - nrSendMetric("roku.http.response.time", deltaMs, {"host": nrExtractHostFromUrl(attr["origUrl"])}) + nrSendMetric("roku.http.response.time", deltaMs, {"domain": attr["domain"]}) end if 'Calculate counts for metrics @@ -731,6 +733,7 @@ function nrAddCommonHTTPAttr(info as Object) as Object "httpCode": info["HttpCode"], "method": info["Method"], "origUrl": info["OrigUrl"], + "domain": nrExtractDomainFromUrl(info["OrigUrl"]), "status": info["Status"], "targetIp": info["TargetIp"], "url": info["Url"] @@ -800,12 +803,12 @@ function nrSendHTTPComplete(info as Object) as Void if m.http_events_enabled then nrSendCustomEvent("RokuSystem", "HTTP_COMPLETE", attr) - host = nrExtractHostFromUrl(attr["origUrl"]) - nrSendMetric("roku.http.complete.connectTime", attr["connectTime"], {"host": host}) - nrSendMetric("roku.http.complete.downSpeed", attr["downloadSpeed"], {"host": host}) - nrSendMetric("roku.http.complete.upSpeed", attr["uploadSpeed"], {"host": host}) - nrSendMetric("roku.http.complete.firstByteTime", attr["transferTime"], {"host": host}) - nrSendMetric("roku.http.complete.dnsTime", attr["dnsLookupTime"], {"host": host}) + domain = nrExtractDomainFromUrl(attr["origUrl"]) + nrSendMetric("roku.http.complete.connectTime", attr["connectTime"], {"domain": domain}) + nrSendMetric("roku.http.complete.downSpeed", attr["downloadSpeed"], {"domain": domain}) + nrSendMetric("roku.http.complete.upSpeed", attr["uploadSpeed"], {"domain": domain}) + nrSendMetric("roku.http.complete.firstByteTime", attr["transferTime"], {"domain": domain}) + nrSendMetric("roku.http.complete.dnsTime", attr["dnsLookupTime"], {"domain": domain}) end function function nrSendBandwidth(info as Object) as Void @@ -1148,7 +1151,7 @@ function isAction(name as String, action as String) as Boolean return r.isMatch(action) end function -function nrExtractHostFromUrl(url as String) as String +function nrExtractDomainFromUrl(url as String) as String r = CreateObject("roRegex", "\/\/|\/", "") arr = r.Split(url) diff --git a/components/NewRelicAgent/NRAgent.xml b/components/NewRelicAgent/NRAgent.xml index dae32ad..86d82bc 100644 --- a/components/NewRelicAgent/NRAgent.xml +++ b/components/NewRelicAgent/NRAgent.xml @@ -13,7 +13,7 @@ - + diff --git a/components/SearchTask.brs b/components/SearchTask.brs index a190efc..a1479c8 100644 --- a/components/SearchTask.brs +++ b/components/SearchTask.brs @@ -44,7 +44,6 @@ function searchTaskMain() 'Send HTTP_RESPONSE action nrSendHttpResponse(m.nr, _url, msg) nrSendLog(m.nr, "Google Search", "URL Request", { "url": _url, "counter": counter, "bodysize": Len(msg) }) - nrSendMetric(m.nr, "roku.http.response", requestTimer.TotalMilliseconds()) ' Update max, min and sum if requestTimer.TotalMilliseconds() > m_max then m_max = requestTimer.TotalMilliseconds() @@ -56,7 +55,6 @@ function searchTaskMain() counter = counter + 1 if countTimer.TotalMilliseconds() > 7500 - nrSendCountMetric(m.nr, "roku.http.request.count", counter, countTimer.TotalMilliseconds()) nrSendSummaryMetric(m.nr, "roku.http.response.summary", countTimer.TotalMilliseconds(), counter, m_sum, m_min, m_max) m_min = 999999 m_max = 0 diff --git a/components/VideoScene.brs b/components/VideoScene.brs index f475003..c12d8d4 100644 --- a/components/VideoScene.brs +++ b/components/VideoScene.brs @@ -22,7 +22,7 @@ function nrRefUpdated() 'setupSingleVideo() 'Setup the video player with a playlist - setupVideoPlaylist() + setupVideoPlaylist(true) 'Setup the video player with a single video and ads 'setupVideoWithAds() @@ -61,10 +61,10 @@ function setupSingleVideo() as void m.video.control = "play" end function -function setupVideoPlaylist() as void +function setupVideoPlaylist(loop as boolean) as void print "Prepare video player with Playlist" - httprange = "http://mirrors.standaloneinstaller.com/video-sample/jellyfish-25-mbps-hd-hevc.m4v" + 'httprange = "http://mirrors.standaloneinstaller.com/video-sample/jellyfish-25-mbps-hd-hevc.m4v" hls = "https://bitdash-a.akamaihd.net/content/MI201109210084_1/m3u8s/f08e80da-bf1d-4e3d-8899-f0f6155f6efa.m3u8" dash = "http://yt-dash-mse-test.commondatastorage.googleapis.com/media/car-20120827-manifest.mpd" @@ -84,6 +84,7 @@ function setupVideoPlaylist() as void m.video.content = playlistContent m.video.contentIsPlaylist = True m.video.control = "play" + m.video.loop = loop end function function setupVideoWithAds() as void