-
Notifications
You must be signed in to change notification settings - Fork 67
Expand file tree
/
Copy pathruntime.js
More file actions
52 lines (48 loc) · 1.6 KB
/
Copy pathruntime.js
File metadata and controls
52 lines (48 loc) · 1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/**
* Copyright 2020-2025 New Relic, Inc. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*/
import { getModeledObject } from './configurable'
import { originTime } from '../constants/runtime'
import { BUILD_ENV, DIST_METHOD, VERSION } from '../constants/env'
/**
* Module level count of harvests. This property will auto-increment each time it is accessed.
* @type {number}
*/
let _harvestCount = 0
const ReadOnly = {
buildEnv: BUILD_ENV,
distMethod: DIST_METHOD,
version: VERSION,
originTime
}
const RuntimeModel = {
/** Agent-specific metadata found in the RUM call response. ex. entityGuid */
appMetadata: {},
customTransaction: undefined,
denyList: undefined,
disabled: false,
harvester: undefined,
isolatedBacklog: false,
isRecording: false, // true when actively recording, false when paused or stopped
loaderType: undefined,
maxBytes: 30000,
obfuscator: undefined,
onerror: undefined,
ptid: undefined,
releaseIds: {},
session: undefined,
timeKeeper: undefined,
registeredEntities: [],
/** a proxy is set in agent-session to track jsAttributes changes for harvesting mechanics */
jsAttributesMetadata: { bytes: 0 },
get harvestCount () { return ++_harvestCount }
}
export const mergeRuntime = (runtime) => {
const modeledObject = getModeledObject(runtime, RuntimeModel)
const readonlyDescriptors = Object.keys(ReadOnly).reduce((descriptors, key) => {
descriptors[key] = { value: ReadOnly[key], writable: false, configurable: true, enumerable: true }
return descriptors
}, {})
return Object.defineProperties(modeledObject, readonlyDescriptors)
}