Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F5984098
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
Sat, Oct 3, 23:11 (1 w, 6 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
7d/0f/647e0c57e59cced10b94094166b3
Default Alt Text
ContextController.js (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment