Skip to content

Instantly share code, notes, and snippets.

@trentm
Created November 20, 2024 19:20
Show Gist options
  • Save trentm/f67edf299645d065f6fe2af4ce9ab894 to your computer and use it in GitHub Desktop.
Save trentm/f67edf299645d065f6fe2af4ce9ab894 to your computer and use it in GitHub Desktop.
diff --git a/packages/opentelemetry-resources/src/detectors/platform/node/ProcessDetectorSync.ts b/packages/opentelemetry-resources/src/detectors/platform/node/ProcessDetectorSync.ts
index e2f9fdbf5..ea62baf9f 100644
--- a/packages/opentelemetry-resources/src/detectors/platform/node/ProcessDetectorSync.ts
+++ b/packages/opentelemetry-resources/src/detectors/platform/node/ProcessDetectorSync.ts
@@ -16,16 +16,16 @@
import { diag } from '@opentelemetry/api';
import {
- SEMRESATTRS_PROCESS_COMMAND,
- SEMRESATTRS_PROCESS_COMMAND_ARGS,
- SEMRESATTRS_PROCESS_EXECUTABLE_NAME,
- SEMRESATTRS_PROCESS_EXECUTABLE_PATH,
- SEMRESATTRS_PROCESS_OWNER,
- SEMRESATTRS_PROCESS_PID,
- SEMRESATTRS_PROCESS_RUNTIME_DESCRIPTION,
- SEMRESATTRS_PROCESS_RUNTIME_NAME,
- SEMRESATTRS_PROCESS_RUNTIME_VERSION,
-} from '@opentelemetry/semantic-conventions';
+ ATTR_PROCESS_COMMAND,
+ ATTR_PROCESS_COMMAND_ARGS,
+ ATTR_PROCESS_EXECUTABLE_NAME,
+ ATTR_PROCESS_EXECUTABLE_PATH,
+ ATTR_PROCESS_OWNER,
+ ATTR_PROCESS_PID,
+ ATTR_PROCESS_RUNTIME_DESCRIPTION,
+ ATTR_PROCESS_RUNTIME_NAME,
+ ATTR_PROCESS_RUNTIME_VERSION,
+} from '@opentelemetry/semantic-conventions/incubating';
import { Resource } from '../../../Resource';
import { DetectorSync, ResourceAttributes } from '../../../types';
import { ResourceDetectionConfig } from '../../../config';
@@ -39,26 +39,26 @@ import * as os from 'os';
class ProcessDetectorSync implements DetectorSync {
detect(_config?: ResourceDetectionConfig): IResource {
const attributes: ResourceAttributes = {
- [SEMRESATTRS_PROCESS_PID]: process.pid,
- [SEMRESATTRS_PROCESS_EXECUTABLE_NAME]: process.title,
- [SEMRESATTRS_PROCESS_EXECUTABLE_PATH]: process.execPath,
- [SEMRESATTRS_PROCESS_COMMAND_ARGS]: [
+ [ATTR_PROCESS_PID]: process.pid,
+ [ATTR_PROCESS_EXECUTABLE_NAME]: process.title,
+ [ATTR_PROCESS_EXECUTABLE_PATH]: process.execPath,
+ [ATTR_PROCESS_COMMAND_ARGS]: [
process.argv[0],
...process.execArgv,
...process.argv.slice(1),
],
- [SEMRESATTRS_PROCESS_RUNTIME_VERSION]: process.versions.node,
- [SEMRESATTRS_PROCESS_RUNTIME_NAME]: 'nodejs',
- [SEMRESATTRS_PROCESS_RUNTIME_DESCRIPTION]: 'Node.js',
+ [ATTR_PROCESS_RUNTIME_VERSION]: process.versions.node,
+ [ATTR_PROCESS_RUNTIME_NAME]: 'nodejs',
+ [ATTR_PROCESS_RUNTIME_DESCRIPTION]: 'Node.js',
};
if (process.argv.length > 1) {
- attributes[SEMRESATTRS_PROCESS_COMMAND] = process.argv[1];
+ attributes[ATTR_PROCESS_COMMAND] = process.argv[1];
}
try {
const userInfo = os.userInfo();
- attributes[SEMRESATTRS_PROCESS_OWNER] = userInfo.username;
+ attributes[ATTR_PROCESS_OWNER] = userInfo.username;
} catch (e) {
diag.debug(`error obtaining process owner: ${e}`);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment