Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F4143963
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}
*
* @see https://wikitech.wikimedia.org/wiki/Metrics_Platform/Contextual_attributes
*/
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
Aug 19 2026, 17:02 (4 w, 4 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
00/f9/9e9a4312679e4d9ddc6fa0b8ba6e
Default Alt Text
ContextController.js (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment