@opentelemetry/resource-detector-container
Advanced tools
Comparing version 0.3.1 to 0.3.2
@@ -49,6 +49,26 @@ "use strict"; | ||
const splitData = rawData.trim().split('\n'); | ||
for (const str of splitData) { | ||
if (str.length >= this.CONTAINER_ID_LENGTH) { | ||
return str.substring(str.length - this.CONTAINER_ID_LENGTH); | ||
for (const line of splitData) { | ||
const lastSlashIdx = line.lastIndexOf('/'); | ||
if (lastSlashIdx === -1) { | ||
continue; | ||
} | ||
const lastSection = line.substring(lastSlashIdx + 1); | ||
const colonIdx = lastSection.lastIndexOf(':'); | ||
if (colonIdx !== -1) { | ||
// since containerd v1.5.0+, containerId is divided by the last colon when the cgroupDriver is systemd: | ||
// https://github.com/containerd/containerd/blob/release/1.5/pkg/cri/server/helpers_linux.go#L64 | ||
return lastSection.substring(colonIdx + 1); | ||
} | ||
else { | ||
let startIdx = lastSection.lastIndexOf('-'); | ||
let endIdx = lastSection.lastIndexOf('.'); | ||
startIdx = startIdx === -1 ? 0 : startIdx + 1; | ||
if (endIdx === -1) { | ||
endIdx = lastSection.length; | ||
} | ||
if (startIdx > endIdx) { | ||
continue; | ||
} | ||
return lastSection.substring(startIdx, endIdx); | ||
} | ||
} | ||
@@ -55,0 +75,0 @@ return undefined; |
@@ -1,2 +0,2 @@ | ||
export declare const VERSION = "0.3.1"; | ||
export declare const VERSION = "0.3.2"; | ||
//# sourceMappingURL=version.d.ts.map |
@@ -20,3 +20,3 @@ "use strict"; | ||
// this is autogenerated file, see scripts/version-update.js | ||
exports.VERSION = '0.3.1'; | ||
exports.VERSION = '0.3.2'; | ||
//# sourceMappingURL=version.js.map |
{ | ||
"name": "@opentelemetry/resource-detector-container", | ||
"version": "0.3.1", | ||
"version": "0.3.2", | ||
"description": "Opentelemetry resource detector to get container resource attributes", | ||
@@ -39,12 +39,12 @@ "main": "build/src/index.js", | ||
"@opentelemetry/api": "^1.0.0", | ||
"@opentelemetry/contrib-test-utils": "^0.34.1", | ||
"@opentelemetry/contrib-test-utils": "^0.34.2", | ||
"@types/mocha": "8.2.3", | ||
"@types/node": "^18.0.0", | ||
"@types/sinon": "10.0.16", | ||
"@types/node": "18.6.5", | ||
"@types/sinon": "10.0.18", | ||
"eslint-plugin-header": "^3.1.1", | ||
"mocha": "7.2.0", | ||
"nock": "13.3.2", | ||
"nock": "13.3.3", | ||
"nyc": "15.1.0", | ||
"rimraf": "5.0.1", | ||
"sinon": "15.0.1", | ||
"rimraf": "5.0.5", | ||
"sinon": "15.2.0", | ||
"ts-mocha": "10.0.0", | ||
@@ -61,3 +61,3 @@ "typescript": "4.4.4" | ||
"homepage": "https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/detectors/node/opentelemetry-resource-detector-container#readme", | ||
"gitHead": "b3d30afe7376760d211b20c4fb45988ac58c1d85" | ||
"gitHead": "a8c225d2febcac561a70ca586d3efd5a84f9f3fa" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
33319
199