@opentelemetry/resources
Version:
OpenTelemetry SDK resources
36 lines • 1.38 kB
JavaScript
;
/**
* Copyright 2020, OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
Object.defineProperty(exports, "__esModule", { value: true });
const Resource_1 = require("../../Resource");
const detectors_1 = require("./detectors");
const DETECTORS = [detectors_1.envDetector, detectors_1.awsEc2Detector, detectors_1.gcpDetector];
/**
* Runs all resource detectors and returns the results merged into a single
* Resource.
*/
exports.detectResources = async () => {
const resources = await Promise.all(DETECTORS.map(d => {
try {
return d.detect();
}
catch (_a) {
return Resource_1.Resource.empty();
}
}));
return resources.reduce((acc, resource) => acc.merge(resource), Resource_1.Resource.createTelemetrySDKResource());
};
//# sourceMappingURL=detect-resources.js.map