Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(opentelemetry-resources): add runtime version information #2727

Merged
merged 18 commits into from
Mar 4, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ class ProcessDetector implements Detector {
[SemanticResourceAttributes.PROCESS_COMMAND]: process.argv[1] || '',
[SemanticResourceAttributes.PROCESS_COMMAND_LINE]:
process.argv.join(' ') || '',
[SemanticResourceAttributes.PROCESS_RUNTIME_VERSION]: process.versions.node,
[SemanticResourceAttributes.PROCESS_RUNTIME_NAME]: 'nodejs',
vmarchaud marked this conversation as resolved.
Show resolved Hide resolved
[SemanticResourceAttributes.PROCESS_RUNTIME_DESCRIPTION]: 'NodeJS',
cuichenli marked this conversation as resolved.
Show resolved Hide resolved
};
return this._getResourceAttributes(processResource, config);
}
Expand All @@ -51,7 +54,8 @@ class ProcessDetector implements Detector {
processResource[SemanticResourceAttributes.PROCESS_EXECUTABLE_PATH] ===
'' ||
processResource[SemanticResourceAttributes.PROCESS_COMMAND] === '' ||
processResource[SemanticResourceAttributes.PROCESS_COMMAND_LINE] === ''
processResource[SemanticResourceAttributes.PROCESS_COMMAND_LINE] === '' ||
processResource[SemanticResourceAttributes.PROCESS_RUNTIME_VERSION] === ''
) {
diag.debug(
'ProcessDetector failed: Unable to find required process resources. '
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,19 @@ describe('processDetector()', () => {
sinon
.stub(process, 'argv')
.value(['/tmp/node', '/home/ot/test.js', 'arg1', 'arg2']);
sinon
.stub(process, 'versions')
.value({'node': '1.4.1'});

const resource: Resource = await processDetector.detect();
assertProcessResource(resource, {
pid: 1234,
name: 'otProcess',
command: '/home/ot/test.js',
commandLine: '/tmp/node /home/ot/test.js arg1 arg2',
version: '1.4.1',
runtimeDescription: 'NodeJS',
runtimeName: 'nodejs',
});
});
it('should return empty resources if title, command and commondLine is missing', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,9 @@ export const assertProcessResource = (
name?: string;
command?: string;
commandLine?: string;
version?: string;
runtimeName?: string;
runtimeDescription?: string;
}
) => {
assert.strictEqual(
Expand All @@ -294,6 +297,24 @@ export const assertProcessResource = (
validations.commandLine
);
}
if (validations.version) {
assert.strictEqual(
resource.attributes[SemanticResourceAttributes.PROCESS_RUNTIME_VERSION],
validations.version
);
}
if (validations.runtimeName) {
assert.strictEqual(
resource.attributes[SemanticResourceAttributes.PROCESS_RUNTIME_NAME],
validations.runtimeName
);
}
if (validations.runtimeDescription) {
assert.strictEqual(
resource.attributes[SemanticResourceAttributes.PROCESS_RUNTIME_DESCRIPTION],
validations.runtimeDescription
);
}
};

/**
Expand Down