@opentelemetry/resources
Advanced tools
Comparing version 0.19.1-alpha.39 to 0.19.1-alpha.43
export * from './Resource'; | ||
export * from './platform'; | ||
export * from './constants'; | ||
export * from './types'; | ||
export * from './config'; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -18,5 +18,4 @@ /* | ||
export * from './platform'; | ||
export * from './constants'; | ||
export * from './types'; | ||
export * from './config'; | ||
//# sourceMappingURL=index.js.map |
@@ -60,5 +60,5 @@ /* | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, Resource.createTelemetrySDKResource()]; | ||
return [2 /*return*/, Resource.empty()]; | ||
}); | ||
}); }; | ||
//# sourceMappingURL=detect-resources.js.map |
@@ -0,2 +1,3 @@ | ||
export * from './default-service-name'; | ||
export * from './detect-resources'; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -16,3 +16,4 @@ /* | ||
*/ | ||
export * from './default-service-name'; | ||
export * from './detect-resources'; | ||
//# sourceMappingURL=index.js.map |
@@ -92,3 +92,3 @@ /* | ||
logResources(resources); | ||
return [2 /*return*/, resources.reduce(function (acc, resource) { return acc.merge(resource); }, Resource.createTelemetrySDKResource())]; | ||
return [2 /*return*/, resources.reduce(function (acc, resource) { return acc.merge(resource); }, Resource.empty())]; | ||
} | ||
@@ -95,0 +95,0 @@ }); |
@@ -54,2 +54,3 @@ /* | ||
import { getEnv } from '@opentelemetry/core'; | ||
import { ResourceAttributes as SemanticResourceAttributes } from '@opentelemetry/semantic-conventions'; | ||
import { Resource, } from '../../../'; | ||
@@ -84,18 +85,21 @@ /** | ||
return __awaiter(this, void 0, void 0, function () { | ||
var rawAttributes, attributes; | ||
var attributes, env, rawAttributes, serviceName, parsedAttributes; | ||
return __generator(this, function (_a) { | ||
try { | ||
rawAttributes = getEnv().OTEL_RESOURCE_ATTRIBUTES; | ||
if (!rawAttributes) { | ||
diag.debug('EnvDetector failed: Environment variable "OTEL_RESOURCE_ATTRIBUTES" is missing.'); | ||
return [2 /*return*/, Resource.empty()]; | ||
attributes = {}; | ||
env = getEnv(); | ||
rawAttributes = env.OTEL_RESOURCE_ATTRIBUTES; | ||
serviceName = env.OTEL_SERVICE_NAME; | ||
if (rawAttributes) { | ||
try { | ||
parsedAttributes = this._parseResourceAttributes(rawAttributes); | ||
Object.assign(attributes, parsedAttributes); | ||
} | ||
attributes = this._parseResourceAttributes(rawAttributes); | ||
return [2 /*return*/, new Resource(attributes)]; | ||
catch (e) { | ||
diag.debug("EnvDetector failed: " + e.message); | ||
} | ||
} | ||
catch (e) { | ||
diag.debug("EnvDetector failed: " + e.message); | ||
return [2 /*return*/, Resource.empty()]; | ||
if (serviceName) { | ||
attributes[SemanticResourceAttributes.SERVICE_NAME] = serviceName; | ||
} | ||
return [2 /*return*/]; | ||
return [2 /*return*/, new Resource(attributes)]; | ||
}); | ||
@@ -102,0 +106,0 @@ }); |
@@ -64,3 +64,4 @@ /* | ||
import { diag } from '@opentelemetry/api'; | ||
import { Resource, PROCESS_RESOURCE, } from '../../../'; | ||
import { ResourceAttributes as SemanticResourceAttributes } from '@opentelemetry/semantic-conventions'; | ||
import { Resource } from '../../../'; | ||
/** | ||
@@ -79,6 +80,6 @@ * ProcessDetector will be used to detect the resources related current process running | ||
processResource = (_a = {}, | ||
_a[PROCESS_RESOURCE.PID] = process.pid, | ||
_a[PROCESS_RESOURCE.NAME] = process.title || '', | ||
_a[PROCESS_RESOURCE.COMMAND] = process.argv[1] || '', | ||
_a[PROCESS_RESOURCE.COMMAND_LINE] = process.argv.join(' ') || '', | ||
_a[SemanticResourceAttributes.PROCESS_PID] = process.pid, | ||
_a[SemanticResourceAttributes.PROCESS_EXECUTABLE_NAME] = process.title || '', | ||
_a[SemanticResourceAttributes.PROCESS_COMMAND] = process.argv[1] || '', | ||
_a[SemanticResourceAttributes.PROCESS_COMMAND_LINE] = process.argv.join(' ') || '', | ||
_a); | ||
@@ -97,6 +98,8 @@ return [2 /*return*/, this._getResourceAttributes(processResource, config)]; | ||
ProcessDetector.prototype._getResourceAttributes = function (processResource, _config) { | ||
if (processResource[PROCESS_RESOURCE.NAME] === '' || | ||
processResource[PROCESS_RESOURCE.PATH] === '' || | ||
processResource[PROCESS_RESOURCE.COMMAND] === '' || | ||
processResource[PROCESS_RESOURCE.COMMAND_LINE] === '') { | ||
if (processResource[SemanticResourceAttributes.PROCESS_EXECUTABLE_NAME] === | ||
'' || | ||
processResource[SemanticResourceAttributes.PROCESS_EXECUTABLE_PATH] === | ||
'' || | ||
processResource[SemanticResourceAttributes.PROCESS_COMMAND] === '' || | ||
processResource[SemanticResourceAttributes.PROCESS_COMMAND_LINE] === '') { | ||
diag.debug('ProcessDetector failed: Unable to find required process resources. '); | ||
@@ -103,0 +106,0 @@ return Resource.empty(); |
@@ -0,3 +1,4 @@ | ||
export * from './default-service-name'; | ||
export * from './detect-resources'; | ||
export * from './detectors'; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -16,4 +16,5 @@ /* | ||
*/ | ||
export * from './default-service-name'; | ||
export * from './detect-resources'; | ||
export * from './detectors'; | ||
//# sourceMappingURL=index.js.map |
@@ -21,3 +21,3 @@ import { ResourceAttributes } from './types'; | ||
*/ | ||
static createTelemetrySDKResource(): Resource; | ||
static default(): Resource; | ||
constructor( | ||
@@ -24,0 +24,0 @@ /** |
@@ -16,4 +16,5 @@ /* | ||
*/ | ||
import { ResourceAttributes as SemanticResourceAttributes } from '@opentelemetry/semantic-conventions'; | ||
import { SDK_INFO } from '@opentelemetry/core'; | ||
import { TELEMETRY_SDK_RESOURCE } from './constants'; | ||
import { defaultServiceName } from './platform'; | ||
/** | ||
@@ -42,8 +43,9 @@ * A Resource describes the entity for which a signals (metrics or trace) are | ||
*/ | ||
Resource.createTelemetrySDKResource = function () { | ||
Resource.default = function () { | ||
var _a; | ||
return new Resource((_a = {}, | ||
_a[TELEMETRY_SDK_RESOURCE.LANGUAGE] = SDK_INFO.LANGUAGE, | ||
_a[TELEMETRY_SDK_RESOURCE.NAME] = SDK_INFO.NAME, | ||
_a[TELEMETRY_SDK_RESOURCE.VERSION] = SDK_INFO.VERSION, | ||
_a[SemanticResourceAttributes.SERVICE_NAME] = defaultServiceName(), | ||
_a[SemanticResourceAttributes.TELEMETRY_SDK_LANGUAGE] = SDK_INFO[SemanticResourceAttributes.TELEMETRY_SDK_LANGUAGE], | ||
_a[SemanticResourceAttributes.TELEMETRY_SDK_NAME] = SDK_INFO[SemanticResourceAttributes.TELEMETRY_SDK_NAME], | ||
_a[SemanticResourceAttributes.TELEMETRY_SDK_VERSION] = SDK_INFO[SemanticResourceAttributes.TELEMETRY_SDK_VERSION], | ||
_a)); | ||
@@ -50,0 +52,0 @@ }; |
export * from './Resource'; | ||
export * from './platform'; | ||
export * from './constants'; | ||
export * from './types'; | ||
export * from './config'; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -30,5 +30,4 @@ "use strict"; | ||
__exportStar(require("./platform"), exports); | ||
__exportStar(require("./constants"), exports); | ||
__exportStar(require("./types"), exports); | ||
__exportStar(require("./config"), exports); | ||
//# sourceMappingURL=index.js.map |
@@ -26,5 +26,5 @@ "use strict"; | ||
const detectResources = async () => { | ||
return Resource_1.Resource.createTelemetrySDKResource(); | ||
return Resource_1.Resource.empty(); | ||
}; | ||
exports.detectResources = detectResources; | ||
//# sourceMappingURL=detect-resources.js.map |
@@ -0,2 +1,3 @@ | ||
export * from './default-service-name'; | ||
export * from './detect-resources'; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -28,3 +28,4 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
__exportStar(require("./default-service-name"), exports); | ||
__exportStar(require("./detect-resources"), exports); | ||
//# sourceMappingURL=index.js.map |
@@ -43,3 +43,3 @@ "use strict"; | ||
logResources(resources); | ||
return resources.reduce((acc, resource) => acc.merge(resource), Resource_1.Resource.createTelemetrySDKResource()); | ||
return resources.reduce((acc, resource) => acc.merge(resource), Resource_1.Resource.empty()); | ||
}; | ||
@@ -46,0 +46,0 @@ exports.detectResources = detectResources; |
@@ -21,2 +21,3 @@ "use strict"; | ||
const core_1 = require("@opentelemetry/core"); | ||
const semantic_conventions_1 = require("@opentelemetry/semantic-conventions"); | ||
const __1 = require("../../../"); | ||
@@ -50,15 +51,19 @@ /** | ||
async detect(_config) { | ||
try { | ||
const rawAttributes = core_1.getEnv().OTEL_RESOURCE_ATTRIBUTES; | ||
if (!rawAttributes) { | ||
api_1.diag.debug('EnvDetector failed: Environment variable "OTEL_RESOURCE_ATTRIBUTES" is missing.'); | ||
return __1.Resource.empty(); | ||
const attributes = {}; | ||
const env = core_1.getEnv(); | ||
const rawAttributes = env.OTEL_RESOURCE_ATTRIBUTES; | ||
const serviceName = env.OTEL_SERVICE_NAME; | ||
if (rawAttributes) { | ||
try { | ||
const parsedAttributes = this._parseResourceAttributes(rawAttributes); | ||
Object.assign(attributes, parsedAttributes); | ||
} | ||
const attributes = this._parseResourceAttributes(rawAttributes); | ||
return new __1.Resource(attributes); | ||
catch (e) { | ||
api_1.diag.debug(`EnvDetector failed: ${e.message}`); | ||
} | ||
} | ||
catch (e) { | ||
api_1.diag.debug(`EnvDetector failed: ${e.message}`); | ||
return __1.Resource.empty(); | ||
if (serviceName) { | ||
attributes[semantic_conventions_1.ResourceAttributes.SERVICE_NAME] = serviceName; | ||
} | ||
return new __1.Resource(attributes); | ||
} | ||
@@ -65,0 +70,0 @@ /** |
@@ -20,2 +20,3 @@ "use strict"; | ||
const api_1 = require("@opentelemetry/api"); | ||
const semantic_conventions_1 = require("@opentelemetry/semantic-conventions"); | ||
const __1 = require("../../../"); | ||
@@ -29,6 +30,6 @@ /** | ||
const processResource = { | ||
[__1.PROCESS_RESOURCE.PID]: process.pid, | ||
[__1.PROCESS_RESOURCE.NAME]: process.title || '', | ||
[__1.PROCESS_RESOURCE.COMMAND]: process.argv[1] || '', | ||
[__1.PROCESS_RESOURCE.COMMAND_LINE]: process.argv.join(' ') || '', | ||
[semantic_conventions_1.ResourceAttributes.PROCESS_PID]: process.pid, | ||
[semantic_conventions_1.ResourceAttributes.PROCESS_EXECUTABLE_NAME]: process.title || '', | ||
[semantic_conventions_1.ResourceAttributes.PROCESS_COMMAND]: process.argv[1] || '', | ||
[semantic_conventions_1.ResourceAttributes.PROCESS_COMMAND_LINE]: process.argv.join(' ') || '', | ||
}; | ||
@@ -45,6 +46,8 @@ return this._getResourceAttributes(processResource, config); | ||
_getResourceAttributes(processResource, _config) { | ||
if (processResource[__1.PROCESS_RESOURCE.NAME] === '' || | ||
processResource[__1.PROCESS_RESOURCE.PATH] === '' || | ||
processResource[__1.PROCESS_RESOURCE.COMMAND] === '' || | ||
processResource[__1.PROCESS_RESOURCE.COMMAND_LINE] === '') { | ||
if (processResource[semantic_conventions_1.ResourceAttributes.PROCESS_EXECUTABLE_NAME] === | ||
'' || | ||
processResource[semantic_conventions_1.ResourceAttributes.PROCESS_EXECUTABLE_PATH] === | ||
'' || | ||
processResource[semantic_conventions_1.ResourceAttributes.PROCESS_COMMAND] === '' || | ||
processResource[semantic_conventions_1.ResourceAttributes.PROCESS_COMMAND_LINE] === '') { | ||
api_1.diag.debug('ProcessDetector failed: Unable to find required process resources. '); | ||
@@ -51,0 +54,0 @@ return __1.Resource.empty(); |
@@ -0,3 +1,4 @@ | ||
export * from './default-service-name'; | ||
export * from './detect-resources'; | ||
export * from './detectors'; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -28,4 +28,5 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
__exportStar(require("./default-service-name"), exports); | ||
__exportStar(require("./detect-resources"), exports); | ||
__exportStar(require("./detectors"), exports); | ||
//# sourceMappingURL=index.js.map |
@@ -21,3 +21,3 @@ import { ResourceAttributes } from './types'; | ||
*/ | ||
static createTelemetrySDKResource(): Resource; | ||
static default(): Resource; | ||
constructor( | ||
@@ -24,0 +24,0 @@ /** |
@@ -19,4 +19,5 @@ "use strict"; | ||
exports.Resource = void 0; | ||
const semantic_conventions_1 = require("@opentelemetry/semantic-conventions"); | ||
const core_1 = require("@opentelemetry/core"); | ||
const constants_1 = require("./constants"); | ||
const platform_1 = require("./platform"); | ||
/** | ||
@@ -45,7 +46,8 @@ * A Resource describes the entity for which a signals (metrics or trace) are | ||
*/ | ||
static createTelemetrySDKResource() { | ||
static default() { | ||
return new Resource({ | ||
[constants_1.TELEMETRY_SDK_RESOURCE.LANGUAGE]: core_1.SDK_INFO.LANGUAGE, | ||
[constants_1.TELEMETRY_SDK_RESOURCE.NAME]: core_1.SDK_INFO.NAME, | ||
[constants_1.TELEMETRY_SDK_RESOURCE.VERSION]: core_1.SDK_INFO.VERSION, | ||
[semantic_conventions_1.ResourceAttributes.SERVICE_NAME]: platform_1.defaultServiceName(), | ||
[semantic_conventions_1.ResourceAttributes.TELEMETRY_SDK_LANGUAGE]: core_1.SDK_INFO[semantic_conventions_1.ResourceAttributes.TELEMETRY_SDK_LANGUAGE], | ||
[semantic_conventions_1.ResourceAttributes.TELEMETRY_SDK_NAME]: core_1.SDK_INFO[semantic_conventions_1.ResourceAttributes.TELEMETRY_SDK_NAME], | ||
[semantic_conventions_1.ResourceAttributes.TELEMETRY_SDK_VERSION]: core_1.SDK_INFO[semantic_conventions_1.ResourceAttributes.TELEMETRY_SDK_VERSION], | ||
}); | ||
@@ -52,0 +54,0 @@ } |
{ | ||
"name": "@opentelemetry/resources", | ||
"version": "0.19.1-alpha.39+23ba4bfd", | ||
"version": "0.19.1-alpha.43+d5517812", | ||
"description": "OpenTelemetry SDK resources", | ||
@@ -51,8 +51,7 @@ "main": "build/src/index.js", | ||
"devDependencies": { | ||
"@opentelemetry/api": "^1.0.0-rc.0", | ||
"@opentelemetry/api": "^0.20.0", | ||
"@types/mocha": "8.2.2", | ||
"@types/node": "14.14.41", | ||
"@types/node": "14.14.43", | ||
"@types/sinon": "9.0.11", | ||
"codecov": "3.8.1", | ||
"gts": "3.1.0", | ||
"mocha": "7.2.0", | ||
@@ -65,11 +64,12 @@ "nock": "12.0.3", | ||
"ts-node": "9.1.1", | ||
"typescript": "4.2.4" | ||
"typescript": "4.3.2" | ||
}, | ||
"peerDependencies": { | ||
"@opentelemetry/api": "^1.0.0-rc.0" | ||
"@opentelemetry/api": "^0.20.0" | ||
}, | ||
"dependencies": { | ||
"@opentelemetry/core": "^0.19.1-alpha.39+23ba4bfd" | ||
"@opentelemetry/core": "^0.19.1-alpha.43+d5517812", | ||
"@opentelemetry/semantic-conventions": "^0.19.1-alpha.43+d5517812" | ||
}, | ||
"gitHead": "23ba4bfdc77c8bf594bf0c817320a31f59ca0bd4" | ||
"gitHead": "d5517812b31d9206131bf1df4f8a3b5183ab07fb" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
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
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
13
93
106156
3
1628
+ Added@opentelemetry/semantic-conventions@^0.19.1-alpha.43+d5517812
- Removed@opentelemetry/api@1.9.0(transitive)