Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F2753011
ContextController.js
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
ContextController.js
View Options
const
copyAttributeByName
=
require
(
'./ContextUtils.js'
).
copyAttributeByName
;
const
isValidSample
=
require
(
'./StreamConfigUtils.js'
).
isValidSample
;
/**
* Add context attributes requested in stream configuration.
*
* @param {Integration} integration
* @constructor
*/
function
ContextController
(
integration
)
{
this
.
integration
=
integration
;
}
/**
* Mix the context attributes requested in stream configuration into the given event data.
*
* @param {MetricsPlatformEventData} eventData
* @param {StreamConfig} streamConfig
* @return {MetricsPlatformEventData}
*/
ContextController
.
prototype
.
addRequestedValues
=
function
(
eventData
,
streamConfig
)
{
let
requestedValues
=
streamConfig
&&
streamConfig
.
producers
&&
streamConfig
.
producers
.
metrics_platform_client
&&
streamConfig
.
producers
.
metrics_platform_client
.
provide_values
;
if
(
!
Array
.
isArray
(
requestedValues
)
)
{
requestedValues
=
[];
}
const
contextAttributes
=
this
.
integration
.
getContextAttributes
();
requestedValues
.
concat
(
[
'agent_client_platform'
,
'agent_client_platform_family'
]
)
.
forEach
(
(
requestedValue
)
=>
copyAttributeByName
(
contextAttributes
,
eventData
,
requestedValue
)
);
// Record sampling unit and rate. See https://phabricator.wikimedia.org/T310693 for more
// detail.
if
(
streamConfig
.
sample
&&
isValidSample
(
streamConfig
.
sample
)
)
{
eventData
.
sample
=
streamConfig
.
sample
;
}
return
eventData
;
};
module
.
exports
=
ContextController
;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Jul 3, 20:39 (1 d, 7 h)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
76/81/a1c1e32d0649057b7d30e8dad66a
Default Alt Text
ContextController.js (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment