@opentelemetry/resources
Advanced tools
Comparing version 0.16.1-alpha.18 to 0.16.1-alpha.20
@@ -1,2 +0,1 @@ | ||
import { Logger } from '@opentelemetry/api'; | ||
import type { Detector } from './types'; | ||
@@ -7,14 +6,4 @@ /** | ||
export interface ResourceDetectionConfig { | ||
/** Optional Logger. */ | ||
logger?: Logger; | ||
detectors?: Array<Detector>; | ||
} | ||
/** | ||
* ResourceDetectionConfigWithLogger provides an interface for interacting with | ||
* {@link ResourceDetectionConfig} instances that must have a logger defined. | ||
*/ | ||
export interface ResourceDetectionConfigWithLogger extends ResourceDetectionConfig { | ||
/** Required Logger */ | ||
logger: Logger; | ||
} | ||
//# sourceMappingURL=config.d.ts.map |
@@ -29,21 +29,16 @@ "use strict"; | ||
const detectResources = async (config = {}) => { | ||
const internalConfig = Object.assign({ | ||
logger: new api_1.NoopLogger(), | ||
}, config); | ||
const internalConfig = Object.assign(config); | ||
const resources = await Promise.all((internalConfig.detectors || []).map(async (d) => { | ||
var _a, _b; | ||
try { | ||
const resource = await d.detect(internalConfig); | ||
(_a = config.logger) === null || _a === void 0 ? void 0 : _a.debug(`${d.constructor.name} found resource.`, resource); | ||
api_1.diag.debug(`${d.constructor.name} found resource.`, resource); | ||
return resource; | ||
} | ||
catch (e) { | ||
(_b = config.logger) === null || _b === void 0 ? void 0 : _b.debug(`${d.constructor.name} failed: ${e.message}`); | ||
api_1.diag.debug(`${d.constructor.name} failed: ${e.message}`); | ||
return Resource_1.Resource.empty(); | ||
} | ||
})); | ||
// Log Resources only if there is a user-provided logger | ||
if (config.logger) { | ||
logResources(config.logger, resources); | ||
} | ||
// Future check if verbose logging is enabled issue #1903 | ||
logResources(resources); | ||
return resources.reduce((acc, resource) => acc.merge(resource), Resource_1.Resource.createTelemetrySDKResource()); | ||
@@ -55,6 +50,5 @@ }; | ||
* | ||
* @param logger The {@link Logger} to write the debug information to. | ||
* @param resources The array of {@link Resource} that should be logged. Empty entried will be ignored. | ||
*/ | ||
const logResources = (logger, resources) => { | ||
const logResources = (resources) => { | ||
resources.forEach(resource => { | ||
@@ -69,3 +63,3 @@ // Print only populated resources | ||
}); | ||
logger.debug(resourceDebugString); | ||
api_1.diag.verbose(resourceDebugString); | ||
} | ||
@@ -72,0 +66,0 @@ }); |
@@ -1,2 +0,2 @@ | ||
import { Detector, Resource, ResourceDetectionConfigWithLogger } from '../../../'; | ||
import { Detector, Resource, ResourceDetectionConfig } from '../../../'; | ||
/** | ||
@@ -17,5 +17,5 @@ * EnvDetector can be used to detect the presence of and create a Resource | ||
* | ||
* @param config The resource detection config with a required logger | ||
* @param config The resource detection config | ||
*/ | ||
detect(config: ResourceDetectionConfigWithLogger): Promise<Resource>; | ||
detect(_config?: ResourceDetectionConfig): Promise<Resource>; | ||
/** | ||
@@ -22,0 +22,0 @@ * Creates an attribute map from the OTEL_RESOURCE_ATTRIBUTES environment |
@@ -19,2 +19,3 @@ "use strict"; | ||
exports.envDetector = void 0; | ||
const api_1 = require("@opentelemetry/api"); | ||
const core_1 = require("@opentelemetry/core"); | ||
@@ -46,9 +47,9 @@ const __1 = require("../../../"); | ||
* | ||
* @param config The resource detection config with a required logger | ||
* @param config The resource detection config | ||
*/ | ||
async detect(config) { | ||
async detect(_config) { | ||
try { | ||
const rawAttributes = core_1.getEnv().OTEL_RESOURCE_ATTRIBUTES; | ||
if (!rawAttributes) { | ||
config.logger.debug('EnvDetector failed: Environment variable "OTEL_RESOURCE_ATTRIBUTES" is missing.'); | ||
api_1.diag.debug('EnvDetector failed: Environment variable "OTEL_RESOURCE_ATTRIBUTES" is missing.'); | ||
return __1.Resource.empty(); | ||
@@ -60,3 +61,3 @@ } | ||
catch (e) { | ||
config.logger.debug(`EnvDetector failed: ${e.message}`); | ||
api_1.diag.debug(`EnvDetector failed: ${e.message}`); | ||
return __1.Resource.empty(); | ||
@@ -63,0 +64,0 @@ } |
@@ -1,8 +0,8 @@ | ||
import { Detector, Resource, ResourceDetectionConfigWithLogger } from '../../../'; | ||
import { Detector, Resource, ResourceDetectionConfig } from '../../../'; | ||
/** | ||
* ProcessDetector will be used to detect the resoureces related current process running | ||
* and being instumented from the NodeJS Process module. | ||
* ProcessDetector will be used to detect the resources related current process running | ||
* and being instrumented from the NodeJS Process module. | ||
*/ | ||
declare class ProcessDetector implements Detector { | ||
detect(config: ResourceDetectionConfigWithLogger): Promise<Resource>; | ||
detect(config?: ResourceDetectionConfig): Promise<Resource>; | ||
/** | ||
@@ -9,0 +9,0 @@ * Validates process resource attribute map from process varaibls |
@@ -19,6 +19,7 @@ "use strict"; | ||
exports.processDetector = void 0; | ||
const api_1 = require("@opentelemetry/api"); | ||
const __1 = require("../../../"); | ||
/** | ||
* ProcessDetector will be used to detect the resoureces related current process running | ||
* and being instumented from the NodeJS Process module. | ||
* ProcessDetector will be used to detect the resources related current process running | ||
* and being instrumented from the NodeJS Process module. | ||
*/ | ||
@@ -42,3 +43,3 @@ class ProcessDetector { | ||
*/ | ||
_getResourceAttributes(processResource, config) { | ||
_getResourceAttributes(processResource, _config) { | ||
if (processResource[__1.PROCESS_RESOURCE.NAME] === '' || | ||
@@ -48,3 +49,3 @@ processResource[__1.PROCESS_RESOURCE.PATH] === '' || | ||
processResource[__1.PROCESS_RESOURCE.COMMAND_LINE] === '') { | ||
config.logger.debug('ProcessDetector failed: Unable to find required process resources. '); | ||
api_1.diag.debug('ProcessDetector failed: Unable to find required process resources. '); | ||
return __1.Resource.empty(); | ||
@@ -51,0 +52,0 @@ } |
import { Resource } from './Resource'; | ||
import { ResourceDetectionConfigWithLogger } from './config'; | ||
import { ResourceDetectionConfig } from './config'; | ||
/** Interface for Resource attributes */ | ||
@@ -12,4 +12,4 @@ export interface ResourceAttributes { | ||
export interface Detector { | ||
detect(config: ResourceDetectionConfigWithLogger): Promise<Resource>; | ||
detect(config?: ResourceDetectionConfig): Promise<Resource>; | ||
} | ||
//# sourceMappingURL=types.d.ts.map |
{ | ||
"name": "@opentelemetry/resources", | ||
"version": "0.16.1-alpha.18+9f965b0c", | ||
"version": "0.16.1-alpha.20+62f8695d", | ||
"description": "OpenTelemetry SDK resources", | ||
@@ -61,6 +61,6 @@ "main": "build/src/index.js", | ||
"dependencies": { | ||
"@opentelemetry/api": "^0.16.0", | ||
"@opentelemetry/core": "^0.16.1-alpha.18+9f965b0c" | ||
"@opentelemetry/api": "^0.16.1-alpha.20+62f8695d", | ||
"@opentelemetry/core": "^0.16.1-alpha.20+62f8695d" | ||
}, | ||
"gitHead": "9f965b0c749108df00bbe44eeab84d79b04bb0a4" | ||
"gitHead": "62f8695d3fe5309c62418a1043bc6e8a176bc11f" | ||
} |
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
61426
904
- Removed@opentelemetry/api@0.16.0(transitive)