{"version":3,"file":"HostDetectorSync.js","sourceRoot":"","sources":["../../../../../src/detectors/platform/node/HostDetectorSync.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,8EAI6C;AAC7C,gDAA6C;AAG7C,2BAAoC;AACpC,mCAAwC;AACxC,4DAAyD;AAEzD;;;GAGG;AACH,MAAM,gBAAgB;IACpB,MAAM,CAAC,OAAiC;QACtC,MAAM,UAAU,GAAuB;YACrC,CAAC,4CAAqB,CAAC,EAAE,IAAA,aAAQ,GAAE;YACnC,CAAC,4CAAqB,CAAC,EAAE,IAAA,qBAAa,EAAC,IAAA,SAAI,GAAE,CAAC;SAC/C,CAAC;QAEF,OAAO,IAAI,mBAAQ,CAAC,UAAU,EAAE,IAAI,CAAC,mBAAmB,EAAE,CAAC,CAAC;IAC9D,CAAC;IAEO,mBAAmB;QACzB,OAAO,IAAA,2BAAY,GAAE,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE;YACrC,MAAM,UAAU,GAAuB,EAAE,CAAC;YAC1C,IAAI,SAAS,EAAE;gBACb,UAAU,CAAC,0CAAmB,CAAC,GAAG,SAAS,CAAC;aAC7C;YACD,OAAO,UAAU,CAAC;QACpB,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAEY,QAAA,gBAAgB,GAAG,IAAI,gBAAgB,EAAE,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n SEMRESATTRS_HOST_ARCH,\n SEMRESATTRS_HOST_ID,\n SEMRESATTRS_HOST_NAME,\n} from '@opentelemetry/semantic-conventions';\nimport { Resource } from '../../../Resource';\nimport { DetectorSync, ResourceAttributes } from '../../../types';\nimport { ResourceDetectionConfig } from '../../../config';\nimport { arch, hostname } from 'os';\nimport { normalizeArch } from './utils';\nimport { getMachineId } from './machine-id/getMachineId';\n\n/**\n * HostDetectorSync detects the resources related to the host current process is\n * running on. Currently only non-cloud-based attributes are included.\n */\nclass HostDetectorSync implements DetectorSync {\n detect(_config?: ResourceDetectionConfig): Resource {\n const attributes: ResourceAttributes = {\n [SEMRESATTRS_HOST_NAME]: hostname(),\n [SEMRESATTRS_HOST_ARCH]: normalizeArch(arch()),\n };\n\n return new Resource(attributes, this._getAsyncAttributes());\n }\n\n private _getAsyncAttributes(): Promise {\n return getMachineId().then(machineId => {\n const attributes: ResourceAttributes = {};\n if (machineId) {\n attributes[SEMRESATTRS_HOST_ID] = machineId;\n }\n return attributes;\n });\n }\n}\n\nexport const hostDetectorSync = new HostDetectorSync();\n"]}