Skip to content

Commit 9baa26d

Browse files
[ci-app] Add Configuration Metadata (#1263)
1 parent bf54af2 commit 9baa26d

File tree

4 files changed

+62
-2
lines changed

4 files changed

+62
-2
lines changed

packages/dd-trace/src/plugins/util/ci-app-spec.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,10 @@
1717
"ci.stage.name",
1818
"git.commit.sha",
1919
"git.branch",
20-
"git.tag"
20+
"git.tag",
21+
"os.platform",
22+
"os.version",
23+
"os.architecture",
24+
"runtime.name",
25+
"runtime.version"
2126
]
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
const os = require('os')
2+
3+
const OS_PLATFORM = 'os.platform'
4+
const OS_VERSION = 'os.version'
5+
const OS_ARCHITECTURE = 'os.architecture'
6+
const RUNTIME_NAME = 'runtime.name'
7+
const RUNTIME_VERSION = 'runtime.version'
8+
9+
function getRuntimeAndOSMetadata () {
10+
return {
11+
[RUNTIME_VERSION]: process.version,
12+
[OS_ARCHITECTURE]: process.arch,
13+
[OS_PLATFORM]: process.platform,
14+
[RUNTIME_NAME]: 'node',
15+
[OS_VERSION]: os.release()
16+
}
17+
}
18+
19+
module.exports = {
20+
getRuntimeAndOSMetadata,
21+
OS_PLATFORM,
22+
OS_VERSION,
23+
OS_ARCHITECTURE,
24+
RUNTIME_NAME,
25+
RUNTIME_VERSION
26+
}

packages/dd-trace/src/plugins/util/test.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
const { getGitMetadata, GIT_BRANCH, GIT_COMMIT_SHA, GIT_REPOSITORY_URL } = require('./git')
22
const { getCIMetadata } = require('./ci')
3+
const { getRuntimeAndOSMetadata } = require('./env')
34

45
const TEST_FRAMEWORK = 'test.framework'
56
const TEST_TYPE = 'test.type'
@@ -27,9 +28,12 @@ function getTestEnvironmentMetadata (testFramework) {
2728

2829
const gitMetadata = getGitMetadata({ commitSHA, branch, repositoryUrl })
2930

31+
const runtimeAndOSMetadata = getRuntimeAndOSMetadata()
32+
3033
return {
3134
[TEST_FRAMEWORK]: testFramework,
3235
...gitMetadata,
33-
...ciMetadata
36+
...ciMetadata,
37+
...runtimeAndOSMetadata
3438
}
3539
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
const os = require('os')
2+
const {
3+
getRuntimeAndOSMetadata,
4+
OS_ARCHITECTURE,
5+
OS_PLATFORM,
6+
OS_VERSION,
7+
RUNTIME_NAME,
8+
RUNTIME_VERSION
9+
} = require('../../../src/plugins/util/env')
10+
11+
describe('env', () => {
12+
it('reads runtime and OS metadata', () => {
13+
const envMetadata = getRuntimeAndOSMetadata()
14+
15+
expect(envMetadata).to.eql(
16+
{
17+
[RUNTIME_VERSION]: process.version,
18+
[OS_ARCHITECTURE]: process.arch,
19+
[OS_PLATFORM]: process.platform,
20+
[RUNTIME_NAME]: 'node',
21+
[OS_VERSION]: os.release()
22+
}
23+
)
24+
})
25+
})

0 commit comments

Comments
 (0)