@rsdk/core 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintignore +4 -0
- package/.eslintrc.js +4 -0
- package/.prettierignore +1 -0
- package/.prettierrc.json +1 -0
- package/dist/app/platform.app.d.ts +28 -0
- package/dist/app/platform.app.js +49 -0
- package/dist/app/platform.app.js.map +1 -0
- package/dist/app-metadata/app-metadata.const.d.ts +3 -0
- package/dist/app-metadata/app-metadata.const.js +7 -0
- package/dist/app-metadata/app-metadata.const.js.map +1 -0
- package/dist/app-metadata/app-metadata.module.d.ts +5 -0
- package/dist/app-metadata/app-metadata.module.js +41 -0
- package/dist/app-metadata/app-metadata.module.js.map +1 -0
- package/dist/app-metadata/app-name.const.d.ts +1 -0
- package/dist/app-metadata/app-name.const.js +5 -0
- package/dist/app-metadata/app-name.const.js.map +1 -0
- package/dist/app-metadata/app-name.validator.d.ts +2 -0
- package/dist/app-metadata/app-name.validator.js +14 -0
- package/dist/app-metadata/app-name.validator.js.map +1 -0
- package/dist/app-metadata/decorators/app-name.decorator.d.ts +1 -0
- package/dist/app-metadata/decorators/app-name.decorator.js +8 -0
- package/dist/app-metadata/decorators/app-name.decorator.js.map +1 -0
- package/dist/app-metadata/decorators/index.d.ts +1 -0
- package/dist/app-metadata/decorators/index.js +18 -0
- package/dist/app-metadata/decorators/index.js.map +1 -0
- package/dist/app-metadata/exceptions/app-name-validation.exception.d.ts +4 -0
- package/dist/app-metadata/exceptions/app-name-validation.exception.js +38 -0
- package/dist/app-metadata/exceptions/app-name-validation.exception.js.map +1 -0
- package/dist/app-metadata/exceptions/index.d.ts +1 -0
- package/dist/app-metadata/exceptions/index.js +18 -0
- package/dist/app-metadata/exceptions/index.js.map +1 -0
- package/dist/app-metadata/index.d.ts +2 -0
- package/dist/app-metadata/index.js +19 -0
- package/dist/app-metadata/index.js.map +1 -0
- package/dist/config/additional-source/additional-source.initializer.d.ts +38 -0
- package/dist/config/additional-source/additional-source.initializer.js +130 -0
- package/dist/config/additional-source/additional-source.initializer.js.map +1 -0
- package/dist/config/additional-source/additional-source.module.d.ts +24 -0
- package/dist/config/additional-source/additional-source.module.js +32 -0
- package/dist/config/additional-source/additional-source.module.js.map +1 -0
- package/dist/config/config-reload.indicator.d.ts +8 -0
- package/dist/config/config-reload.indicator.js +42 -0
- package/dist/config/config-reload.indicator.js.map +1 -0
- package/dist/config/config.abstract.d.ts +19 -0
- package/dist/config/config.abstract.js +57 -0
- package/dist/config/config.abstract.js.map +1 -0
- package/dist/config/config.module.d.ts +121 -0
- package/dist/config/config.module.js +271 -0
- package/dist/config/config.module.js.map +1 -0
- package/dist/config/exceptions/config-not-bootstrapped.exception.d.ts +4 -0
- package/dist/config/exceptions/config-not-bootstrapped.exception.js +30 -0
- package/dist/config/exceptions/config-not-bootstrapped.exception.js.map +1 -0
- package/dist/config/exceptions/config-property-metadata-not-found.d.ts +4 -0
- package/dist/config/exceptions/config-property-metadata-not-found.js +13 -0
- package/dist/config/exceptions/config-property-metadata-not-found.js.map +1 -0
- package/dist/config/exceptions/index.d.ts +3 -0
- package/dist/config/exceptions/index.js +22 -0
- package/dist/config/exceptions/index.js.map +1 -0
- package/dist/config/exceptions/property.exception.d.ts +5 -0
- package/dist/config/exceptions/property.exception.js +18 -0
- package/dist/config/exceptions/property.exception.js.map +1 -0
- package/dist/config/index.d.ts +10 -0
- package/dist/config/index.js +29 -0
- package/dist/config/index.js.map +1 -0
- package/dist/config/metadata/config-metadata.registry.d.ts +17 -0
- package/dist/config/metadata/config-metadata.registry.js +46 -0
- package/dist/config/metadata/config-metadata.registry.js.map +1 -0
- package/dist/config/metadata/decorators/config-section.decorator.d.ts +10 -0
- package/dist/config/metadata/decorators/config-section.decorator.js +19 -0
- package/dist/config/metadata/decorators/config-section.decorator.js.map +1 -0
- package/dist/config/metadata/decorators/declare-property.decorator.d.ts +17 -0
- package/dist/config/metadata/decorators/declare-property.decorator.js +37 -0
- package/dist/config/metadata/decorators/declare-property.decorator.js.map +1 -0
- package/dist/config/metadata/decorators/index.d.ts +4 -0
- package/dist/config/metadata/decorators/index.js +21 -0
- package/dist/config/metadata/decorators/index.js.map +1 -0
- package/dist/config/metadata/decorators/inject-property.decorator.d.ts +19 -0
- package/dist/config/metadata/decorators/inject-property.decorator.js +26 -0
- package/dist/config/metadata/decorators/inject-property.decorator.js.map +1 -0
- package/dist/config/metadata/decorators/property.decorator.d.ts +12 -0
- package/dist/config/metadata/decorators/property.decorator.js +27 -0
- package/dist/config/metadata/decorators/property.decorator.js.map +1 -0
- package/dist/config/metadata/exceptions/duplicate-property.exception.d.ts +4 -0
- package/dist/config/metadata/exceptions/duplicate-property.exception.js +27 -0
- package/dist/config/metadata/exceptions/duplicate-property.exception.js.map +1 -0
- package/dist/config/metadata/exceptions/duplicate-section.exception.d.ts +6 -0
- package/dist/config/metadata/exceptions/duplicate-section.exception.js +27 -0
- package/dist/config/metadata/exceptions/duplicate-section.exception.js.map +1 -0
- package/dist/config/metadata/exceptions/duplicate-source.exception.d.ts +6 -0
- package/dist/config/metadata/exceptions/duplicate-source.exception.js +27 -0
- package/dist/config/metadata/exceptions/duplicate-source.exception.js.map +1 -0
- package/dist/config/metadata/exceptions/index.d.ts +3 -0
- package/dist/config/metadata/exceptions/index.js +20 -0
- package/dist/config/metadata/exceptions/index.js.map +1 -0
- package/dist/config/metadata/index.d.ts +2 -0
- package/dist/config/metadata/index.js +19 -0
- package/dist/config/metadata/index.js.map +1 -0
- package/dist/config/parsers/array.parser.d.ts +11 -0
- package/dist/config/parsers/array.parser.js +33 -0
- package/dist/config/parsers/array.parser.js.map +1 -0
- package/dist/config/parsers/boolean/bool.parser.d.ts +6 -0
- package/dist/config/parsers/boolean/bool.parser.js +20 -0
- package/dist/config/parsers/boolean/bool.parser.js.map +1 -0
- package/dist/config/parsers/boolean/index.d.ts +1 -0
- package/dist/config/parsers/boolean/index.js +18 -0
- package/dist/config/parsers/boolean/index.js.map +1 -0
- package/dist/config/parsers/enum/enum.parser.d.ts +9 -0
- package/dist/config/parsers/enum/enum.parser.js +24 -0
- package/dist/config/parsers/enum/enum.parser.js.map +1 -0
- package/dist/config/parsers/enum/index.d.ts +1 -0
- package/dist/config/parsers/enum/index.js +18 -0
- package/dist/config/parsers/enum/index.js.map +1 -0
- package/dist/config/parsers/index.d.ts +10 -0
- package/dist/config/parsers/index.js +27 -0
- package/dist/config/parsers/index.js.map +1 -0
- package/dist/config/parsers/int/index.d.ts +1 -0
- package/dist/config/parsers/int/index.js +18 -0
- package/dist/config/parsers/int/index.js.map +1 -0
- package/dist/config/parsers/int/int.parser.d.ts +6 -0
- package/dist/config/parsers/int/int.parser.js +20 -0
- package/dist/config/parsers/int/int.parser.js.map +1 -0
- package/dist/config/parsers/number/index.d.ts +1 -0
- package/dist/config/parsers/number/index.js +18 -0
- package/dist/config/parsers/number/index.js.map +1 -0
- package/dist/config/parsers/number/number.parser.d.ts +6 -0
- package/dist/config/parsers/number/number.parser.js +23 -0
- package/dist/config/parsers/number/number.parser.js.map +1 -0
- package/dist/config/parsers/path/fspath.parser.d.ts +8 -0
- package/dist/config/parsers/path/fspath.parser.js +56 -0
- package/dist/config/parsers/path/fspath.parser.js.map +1 -0
- package/dist/config/parsers/path/index.d.ts +1 -0
- package/dist/config/parsers/path/index.js +18 -0
- package/dist/config/parsers/path/index.js.map +1 -0
- package/dist/config/parsers/size/index.d.ts +1 -0
- package/dist/config/parsers/size/index.js +18 -0
- package/dist/config/parsers/size/index.js.map +1 -0
- package/dist/config/parsers/size/size.parser.d.ts +7 -0
- package/dist/config/parsers/size/size.parser.js +21 -0
- package/dist/config/parsers/size/size.parser.js.map +1 -0
- package/dist/config/parsers/string/index.d.ts +1 -0
- package/dist/config/parsers/string/index.js +18 -0
- package/dist/config/parsers/string/index.js.map +1 -0
- package/dist/config/parsers/string/string.parser.d.ts +6 -0
- package/dist/config/parsers/string/string.parser.js +18 -0
- package/dist/config/parsers/string/string.parser.js.map +1 -0
- package/dist/config/parsers/timespan/index.d.ts +1 -0
- package/dist/config/parsers/timespan/index.js +18 -0
- package/dist/config/parsers/timespan/index.js.map +1 -0
- package/dist/config/parsers/timespan/timespan.parser.d.ts +7 -0
- package/dist/config/parsers/timespan/timespan.parser.js +21 -0
- package/dist/config/parsers/timespan/timespan.parser.js.map +1 -0
- package/dist/config/parsers/url/index.d.ts +1 -0
- package/dist/config/parsers/url/index.js +18 -0
- package/dist/config/parsers/url/index.js.map +1 -0
- package/dist/config/parsers/url/url.parser.d.ts +6 -0
- package/dist/config/parsers/url/url.parser.js +18 -0
- package/dist/config/parsers/url/url.parser.js.map +1 -0
- package/dist/config/reload/config-reload.events.d.ts +22 -0
- package/dist/config/reload/config-reload.events.js +19 -0
- package/dist/config/reload/config-reload.events.js.map +1 -0
- package/dist/config/reload/index.d.ts +1 -0
- package/dist/config/reload/index.js +18 -0
- package/dist/config/reload/index.js.map +1 -0
- package/dist/config/sources/base/config-source.abstract.d.ts +23 -0
- package/dist/config/sources/base/config-source.abstract.js +73 -0
- package/dist/config/sources/base/config-source.abstract.js.map +1 -0
- package/dist/config/sources/base/index.d.ts +2 -0
- package/dist/config/sources/base/index.js +19 -0
- package/dist/config/sources/base/index.js.map +1 -0
- package/dist/config/sources/base/reloadable-config-source.abstract.d.ts +12 -0
- package/dist/config/sources/base/reloadable-config-source.abstract.js +30 -0
- package/dist/config/sources/base/reloadable-config-source.abstract.js.map +1 -0
- package/dist/config/sources/config-source.decorator.d.ts +12 -0
- package/dist/config/sources/config-source.decorator.js +22 -0
- package/dist/config/sources/config-source.decorator.js.map +1 -0
- package/dist/config/sources/exceptions/config-source-di.exception.d.ts +6 -0
- package/dist/config/sources/exceptions/config-source-di.exception.js +34 -0
- package/dist/config/sources/exceptions/config-source-di.exception.js.map +1 -0
- package/dist/config/sources/exceptions/config-source.exception.d.ts +4 -0
- package/dist/config/sources/exceptions/config-source.exception.js +11 -0
- package/dist/config/sources/exceptions/config-source.exception.js.map +1 -0
- package/dist/config/sources/exceptions/index.d.ts +2 -0
- package/dist/config/sources/exceptions/index.js +19 -0
- package/dist/config/sources/exceptions/index.js.map +1 -0
- package/dist/config/sources/implementations/json-file.source.d.ts +9 -0
- package/dist/config/sources/implementations/json-file.source.js +46 -0
- package/dist/config/sources/implementations/json-file.source.js.map +1 -0
- package/dist/config/sources/implementations/relodable-json-file.source.d.ts +8 -0
- package/dist/config/sources/implementations/relodable-json-file.source.js +55 -0
- package/dist/config/sources/implementations/relodable-json-file.source.js.map +1 -0
- package/dist/config/sources/index.d.ts +3 -0
- package/dist/config/sources/index.js +20 -0
- package/dist/config/sources/index.js.map +1 -0
- package/dist/config/types.d.ts +65 -0
- package/dist/config/types.js +3 -0
- package/dist/config/types.js.map +1 -0
- package/dist/config/vars.class.d.ts +19 -0
- package/dist/config/vars.class.js +79 -0
- package/dist/config/vars.class.js.map +1 -0
- package/dist/exceptions/base/bootstrap-exception.abstract.d.ts +15 -0
- package/dist/exceptions/base/bootstrap-exception.abstract.js +22 -0
- package/dist/exceptions/base/bootstrap-exception.abstract.js.map +1 -0
- package/dist/exceptions/base/index.d.ts +3 -0
- package/dist/exceptions/base/index.js +20 -0
- package/dist/exceptions/base/index.js.map +1 -0
- package/dist/exceptions/base/pipeline-exception.abstract.d.ts +21 -0
- package/dist/exceptions/base/pipeline-exception.abstract.js +29 -0
- package/dist/exceptions/base/pipeline-exception.abstract.js.map +1 -0
- package/dist/exceptions/base/platform-exception.absract.d.ts +48 -0
- package/dist/exceptions/base/platform-exception.absract.js +49 -0
- package/dist/exceptions/base/platform-exception.absract.js.map +1 -0
- package/dist/exceptions/implementations/bootstrap/double-init.exception.d.ts +4 -0
- package/dist/exceptions/implementations/bootstrap/double-init.exception.js +35 -0
- package/dist/exceptions/implementations/bootstrap/double-init.exception.js.map +1 -0
- package/dist/exceptions/implementations/bootstrap/duplicate-protocol.exception.d.ts +4 -0
- package/dist/exceptions/implementations/bootstrap/duplicate-protocol.exception.js +34 -0
- package/dist/exceptions/implementations/bootstrap/duplicate-protocol.exception.js.map +1 -0
- package/dist/exceptions/implementations/bootstrap/index.d.ts +8 -0
- package/dist/exceptions/implementations/bootstrap/index.js +25 -0
- package/dist/exceptions/implementations/bootstrap/index.js.map +1 -0
- package/dist/exceptions/implementations/bootstrap/no-http.exception.d.ts +4 -0
- package/dist/exceptions/implementations/bootstrap/no-http.exception.js +36 -0
- package/dist/exceptions/implementations/bootstrap/no-http.exception.js.map +1 -0
- package/dist/exceptions/implementations/bootstrap/no-init.exception.d.ts +4 -0
- package/dist/exceptions/implementations/bootstrap/no-init.exception.js +35 -0
- package/dist/exceptions/implementations/bootstrap/no-init.exception.js.map +1 -0
- package/dist/exceptions/implementations/bootstrap/no-matching-transport.exception.d.ts +5 -0
- package/dist/exceptions/implementations/bootstrap/no-matching-transport.exception.js +37 -0
- package/dist/exceptions/implementations/bootstrap/no-matching-transport.exception.js.map +1 -0
- package/dist/exceptions/implementations/bootstrap/sequence.exception.d.ts +4 -0
- package/dist/exceptions/implementations/bootstrap/sequence.exception.js +31 -0
- package/dist/exceptions/implementations/bootstrap/sequence.exception.js.map +1 -0
- package/dist/exceptions/implementations/bootstrap/symbol-key-decoration.exception.d.ts +4 -0
- package/dist/exceptions/implementations/bootstrap/symbol-key-decoration.exception.js +30 -0
- package/dist/exceptions/implementations/bootstrap/symbol-key-decoration.exception.js.map +1 -0
- package/dist/exceptions/implementations/bootstrap/unknown-bootstrap.exception.d.ts +4 -0
- package/dist/exceptions/implementations/bootstrap/unknown-bootstrap.exception.js +27 -0
- package/dist/exceptions/implementations/bootstrap/unknown-bootstrap.exception.js.map +1 -0
- package/dist/exceptions/implementations/index.d.ts +2 -0
- package/dist/exceptions/implementations/index.js +19 -0
- package/dist/exceptions/implementations/index.js.map +1 -0
- package/dist/exceptions/implementations/pipeline/authentication.exception.d.ts +4 -0
- package/dist/exceptions/implementations/pipeline/authentication.exception.js +35 -0
- package/dist/exceptions/implementations/pipeline/authentication.exception.js.map +1 -0
- package/dist/exceptions/implementations/pipeline/conflict.exception.d.ts +4 -0
- package/dist/exceptions/implementations/pipeline/conflict.exception.js +36 -0
- package/dist/exceptions/implementations/pipeline/conflict.exception.js.map +1 -0
- package/dist/exceptions/implementations/pipeline/duplicate-entity.exception.d.ts +4 -0
- package/dist/exceptions/implementations/pipeline/duplicate-entity.exception.js +35 -0
- package/dist/exceptions/implementations/pipeline/duplicate-entity.exception.js.map +1 -0
- package/dist/exceptions/implementations/pipeline/index.d.ts +9 -0
- package/dist/exceptions/implementations/pipeline/index.js +26 -0
- package/dist/exceptions/implementations/pipeline/index.js.map +1 -0
- package/dist/exceptions/implementations/pipeline/input.exception.d.ts +4 -0
- package/dist/exceptions/implementations/pipeline/input.exception.js +35 -0
- package/dist/exceptions/implementations/pipeline/input.exception.js.map +1 -0
- package/dist/exceptions/implementations/pipeline/internal.exception.d.ts +4 -0
- package/dist/exceptions/implementations/pipeline/internal.exception.js +35 -0
- package/dist/exceptions/implementations/pipeline/internal.exception.js.map +1 -0
- package/dist/exceptions/implementations/pipeline/not-allowed.exception.d.ts +4 -0
- package/dist/exceptions/implementations/pipeline/not-allowed.exception.js +35 -0
- package/dist/exceptions/implementations/pipeline/not-allowed.exception.js.map +1 -0
- package/dist/exceptions/implementations/pipeline/not-found.exception.d.ts +4 -0
- package/dist/exceptions/implementations/pipeline/not-found.exception.js +35 -0
- package/dist/exceptions/implementations/pipeline/not-found.exception.js.map +1 -0
- package/dist/exceptions/implementations/pipeline/timeout.exception.d.ts +4 -0
- package/dist/exceptions/implementations/pipeline/timeout.exception.js +34 -0
- package/dist/exceptions/implementations/pipeline/timeout.exception.js.map +1 -0
- package/dist/exceptions/implementations/pipeline/validation.exception.d.ts +4 -0
- package/dist/exceptions/implementations/pipeline/validation.exception.js +13 -0
- package/dist/exceptions/implementations/pipeline/validation.exception.js.map +1 -0
- package/dist/exceptions/index.d.ts +5 -0
- package/dist/exceptions/index.js +24 -0
- package/dist/exceptions/index.js.map +1 -0
- package/dist/exceptions/metadata/decorators/exception.decorator.d.ts +2 -0
- package/dist/exceptions/metadata/decorators/exception.decorator.js +13 -0
- package/dist/exceptions/metadata/decorators/exception.decorator.js.map +1 -0
- package/dist/exceptions/metadata/decorators/index.d.ts +2 -0
- package/dist/exceptions/metadata/decorators/index.js +19 -0
- package/dist/exceptions/metadata/decorators/index.js.map +1 -0
- package/dist/exceptions/metadata/decorators/throws.decorator.d.ts +3 -0
- package/dist/exceptions/metadata/decorators/throws.decorator.js +20 -0
- package/dist/exceptions/metadata/decorators/throws.decorator.js.map +1 -0
- package/dist/exceptions/metadata/exceptions.registry.d.ts +23 -0
- package/dist/exceptions/metadata/exceptions.registry.js +30 -0
- package/dist/exceptions/metadata/exceptions.registry.js.map +1 -0
- package/dist/exceptions/metadata/index.d.ts +2 -0
- package/dist/exceptions/metadata/index.js +19 -0
- package/dist/exceptions/metadata/index.js.map +1 -0
- package/dist/exceptions/types.d.ts +18 -0
- package/dist/exceptions/types.js +23 -0
- package/dist/exceptions/types.js.map +1 -0
- package/dist/exceptions/validation/exception.d.ts +4 -0
- package/dist/exceptions/validation/exception.js +13 -0
- package/dist/exceptions/validation/exception.js.map +1 -0
- package/dist/exceptions.handling/constants.d.ts +3 -0
- package/dist/exceptions.handling/constants.js +7 -0
- package/dist/exceptions.handling/constants.js.map +1 -0
- package/dist/exceptions.handling/global-exceptions.config.d.ts +4 -0
- package/dist/exceptions.handling/global-exceptions.config.js +32 -0
- package/dist/exceptions.handling/global-exceptions.config.js.map +1 -0
- package/dist/exceptions.handling/global-exceptions.filter.d.ts +17 -0
- package/dist/exceptions.handling/global-exceptions.filter.js +83 -0
- package/dist/exceptions.handling/global-exceptions.filter.js.map +1 -0
- package/dist/exceptions.handling/global-exceptions.module.d.ts +26 -0
- package/dist/exceptions.handling/global-exceptions.module.js +47 -0
- package/dist/exceptions.handling/global-exceptions.module.js.map +1 -0
- package/dist/exceptions.handling/index.d.ts +2 -0
- package/dist/exceptions.handling/index.js +19 -0
- package/dist/exceptions.handling/index.js.map +1 -0
- package/dist/exceptions.handling/types.d.ts +81 -0
- package/dist/exceptions.handling/types.js +3 -0
- package/dist/exceptions.handling/types.js.map +1 -0
- package/dist/health/exceptions/health-check.exception.d.ts +5 -0
- package/dist/health/exceptions/health-check.exception.js +24 -0
- package/dist/health/exceptions/health-check.exception.js.map +1 -0
- package/dist/health/exceptions/index.d.ts +1 -0
- package/dist/health/exceptions/index.js +18 -0
- package/dist/health/exceptions/index.js.map +1 -0
- package/dist/health/health.const.d.ts +2 -0
- package/dist/health/health.const.js +6 -0
- package/dist/health/health.const.js.map +1 -0
- package/dist/health/health.module.d.ts +5 -0
- package/dist/health/health.module.js +33 -0
- package/dist/health/health.module.js.map +1 -0
- package/dist/health/health.service.d.ts +14 -0
- package/dist/health/health.service.js +118 -0
- package/dist/health/health.service.js.map +1 -0
- package/dist/health/helpers/check-result.class.d.ts +37 -0
- package/dist/health/helpers/check-result.class.js +49 -0
- package/dist/health/helpers/check-result.class.js.map +1 -0
- package/dist/health/helpers/index.d.ts +1 -0
- package/dist/health/helpers/index.js +18 -0
- package/dist/health/helpers/index.js.map +1 -0
- package/dist/health/index.d.ts +6 -0
- package/dist/health/index.js +23 -0
- package/dist/health/index.js.map +1 -0
- package/dist/health/indicators.abstract/fs-access.indicator.d.ts +27 -0
- package/dist/health/indicators.abstract/fs-access.indicator.js +36 -0
- package/dist/health/indicators.abstract/fs-access.indicator.js.map +1 -0
- package/dist/health/indicators.abstract/index.d.ts +2 -0
- package/dist/health/indicators.abstract/index.js +19 -0
- package/dist/health/indicators.abstract/index.js.map +1 -0
- package/dist/health/indicators.abstract/ping.indicator.d.ts +21 -0
- package/dist/health/indicators.abstract/ping.indicator.js +28 -0
- package/dist/health/indicators.abstract/ping.indicator.js.map +1 -0
- package/dist/health/metadata/index.d.ts +2 -0
- package/dist/health/metadata/index.js +19 -0
- package/dist/health/metadata/index.js.map +1 -0
- package/dist/health/metadata/indicator.decorator.d.ts +5 -0
- package/dist/health/metadata/indicator.decorator.js +16 -0
- package/dist/health/metadata/indicator.decorator.js.map +1 -0
- package/dist/health/metadata/indicators.registry.d.ts +12 -0
- package/dist/health/metadata/indicators.registry.js +26 -0
- package/dist/health/metadata/indicators.registry.js.map +1 -0
- package/dist/health/types.d.ts +45 -0
- package/dist/health/types.js +3 -0
- package/dist/health/types.js.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +44 -0
- package/dist/index.js.map +1 -0
- package/dist/logging/adapters/index.d.ts +1 -0
- package/dist/logging/adapters/index.js +18 -0
- package/dist/logging/adapters/index.js.map +1 -0
- package/dist/logging/adapters/nest-logger.adapter.d.ts +11 -0
- package/dist/logging/adapters/nest-logger.adapter.js +27 -0
- package/dist/logging/adapters/nest-logger.adapter.js.map +1 -0
- package/dist/logging/decorators/index.d.ts +1 -0
- package/dist/logging/decorators/index.js +18 -0
- package/dist/logging/decorators/index.js.map +1 -0
- package/dist/logging/decorators/inject-logger.decorator.d.ts +2 -0
- package/dist/logging/decorators/inject-logger.decorator.js +13 -0
- package/dist/logging/decorators/inject-logger.decorator.js.map +1 -0
- package/dist/logging/helpers.d.ts +2 -0
- package/dist/logging/helpers.js +7 -0
- package/dist/logging/helpers.js.map +1 -0
- package/dist/logging/index.d.ts +4 -0
- package/dist/logging/index.js +21 -0
- package/dist/logging/index.js.map +1 -0
- package/dist/logging/logging.config.d.ts +6 -0
- package/dist/logging/logging.config.js +38 -0
- package/dist/logging/logging.config.js.map +1 -0
- package/dist/logging/logging.module.d.ts +10 -0
- package/dist/logging/logging.module.js +54 -0
- package/dist/logging/logging.module.js.map +1 -0
- package/dist/logging/types.d.ts +2 -0
- package/dist/logging/types.js +3 -0
- package/dist/logging/types.js.map +1 -0
- package/dist/manifest/manifest.d.ts +7 -0
- package/dist/manifest/manifest.js +23 -0
- package/dist/manifest/manifest.js.map +1 -0
- package/dist/metrics/index.d.ts +4 -0
- package/dist/metrics/index.js +27 -0
- package/dist/metrics/index.js.map +1 -0
- package/dist/metrics/metadata/decorators/index.d.ts +1 -0
- package/dist/metrics/metadata/decorators/index.js +18 -0
- package/dist/metrics/metadata/decorators/index.js.map +1 -0
- package/dist/metrics/metadata/decorators/metric.decorator.d.ts +13 -0
- package/dist/metrics/metadata/decorators/metric.decorator.js +11 -0
- package/dist/metrics/metadata/decorators/metric.decorator.js.map +1 -0
- package/dist/metrics/metadata/index.d.ts +2 -0
- package/dist/metrics/metadata/index.js +19 -0
- package/dist/metrics/metadata/index.js.map +1 -0
- package/dist/metrics/metadata/metrics.registry.d.ts +8 -0
- package/dist/metrics/metadata/metrics.registry.js +26 -0
- package/dist/metrics/metadata/metrics.registry.js.map +1 -0
- package/dist/metrics/metrics.config.d.ts +5 -0
- package/dist/metrics/metrics.config.js +36 -0
- package/dist/metrics/metrics.config.js.map +1 -0
- package/dist/metrics/metrics.module.d.ts +35 -0
- package/dist/metrics/metrics.module.js +98 -0
- package/dist/metrics/metrics.module.js.map +1 -0
- package/dist/metrics/types.d.ts +21 -0
- package/dist/metrics/types.js +12 -0
- package/dist/metrics/types.js.map +1 -0
- package/dist/noop.http-adapter.d.ts +32 -0
- package/dist/noop.http-adapter.js +100 -0
- package/dist/noop.http-adapter.js.map +1 -0
- package/dist/platform.context.d.ts +55 -0
- package/dist/platform.context.js +162 -0
- package/dist/platform.context.js.map +1 -0
- package/dist/platform.module.d.ts +8 -0
- package/dist/platform.module.js +61 -0
- package/dist/platform.module.js.map +1 -0
- package/dist/plugin/plugin.module.d.ts +5 -0
- package/dist/plugin/plugin.module.js +22 -0
- package/dist/plugin/plugin.module.js.map +1 -0
- package/dist/tracing/auto-instrumentations.config.d.ts +1 -0
- package/dist/tracing/auto-instrumentations.config.js +35 -0
- package/dist/tracing/auto-instrumentations.config.js.map +1 -0
- package/dist/tracing/constants.d.ts +5 -0
- package/dist/tracing/constants.js +10 -0
- package/dist/tracing/constants.js.map +1 -0
- package/dist/tracing/decorators/index.d.ts +2 -0
- package/dist/tracing/decorators/index.js +19 -0
- package/dist/tracing/decorators/index.js.map +1 -0
- package/dist/tracing/decorators/no-span.decorator.d.ts +5 -0
- package/dist/tracing/decorators/no-span.decorator.js +12 -0
- package/dist/tracing/decorators/no-span.decorator.js.map +1 -0
- package/dist/tracing/decorators/span.decorator.d.ts +6 -0
- package/dist/tracing/decorators/span.decorator.js +18 -0
- package/dist/tracing/decorators/span.decorator.js.map +1 -0
- package/dist/tracing/index.d.ts +1 -0
- package/dist/tracing/index.js +18 -0
- package/dist/tracing/index.js.map +1 -0
- package/dist/tracing/services/index.d.ts +3 -0
- package/dist/tracing/services/index.js +20 -0
- package/dist/tracing/services/index.js.map +1 -0
- package/dist/tracing/services/instrumentation.service.d.ts +10 -0
- package/dist/tracing/services/instrumentation.service.js +138 -0
- package/dist/tracing/services/instrumentation.service.js.map +1 -0
- package/dist/tracing/services/metadata.scanner.d.ts +11 -0
- package/dist/tracing/services/metadata.scanner.js +50 -0
- package/dist/tracing/services/metadata.scanner.js.map +1 -0
- package/dist/tracing/services/trace.injector.d.ts +12 -0
- package/dist/tracing/services/trace.injector.js +119 -0
- package/dist/tracing/services/trace.injector.js.map +1 -0
- package/dist/tracing/tracing.config.d.ts +5 -0
- package/dist/tracing/tracing.config.js +36 -0
- package/dist/tracing/tracing.config.js.map +1 -0
- package/dist/tracing/tracing.module.d.ts +22 -0
- package/dist/tracing/tracing.module.js +118 -0
- package/dist/tracing/tracing.module.js.map +1 -0
- package/dist/transport/transport.module.d.ts +8 -0
- package/dist/transport/transport.module.js +55 -0
- package/dist/transport/transport.module.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types/index.js +21 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/metadata.d.ts +38 -0
- package/dist/types/metadata.js +30 -0
- package/dist/types/metadata.js.map +1 -0
- package/dist/types/options.d.ts +68 -0
- package/dist/types/options.js +3 -0
- package/dist/types/options.js.map +1 -0
- package/dist/types/plugins.d.ts +51 -0
- package/dist/types/plugins.js +6 -0
- package/dist/types/plugins.js.map +1 -0
- package/dist/types/transports.d.ts +85 -0
- package/dist/types/transports.js +11 -0
- package/dist/types/transports.js.map +1 -0
- package/package.json +53 -0
- package/src/app/platform.app.ts +52 -0
- package/src/app-metadata/app-metadata.const.ts +3 -0
- package/src/app-metadata/app-metadata.module.ts +34 -0
- package/src/app-metadata/app-name.const.ts +1 -0
- package/src/app-metadata/app-name.validator.ts +11 -0
- package/src/app-metadata/decorators/app-name.decorator.ts +5 -0
- package/src/app-metadata/decorators/index.ts +1 -0
- package/src/app-metadata/exceptions/app-name-validation.exception.ts +23 -0
- package/src/app-metadata/exceptions/index.ts +1 -0
- package/src/app-metadata/index.ts +2 -0
- package/src/config/additional-source/additional-source.initializer.ts +165 -0
- package/src/config/additional-source/additional-source.module.ts +48 -0
- package/src/config/config-reload.indicator.ts +36 -0
- package/src/config/config.abstract.ts +70 -0
- package/src/config/config.module.ts +330 -0
- package/src/config/exceptions/config-not-bootstrapped.exception.ts +15 -0
- package/src/config/exceptions/config-property-metadata-not-found.ts +9 -0
- package/src/config/exceptions/index.ts +3 -0
- package/src/config/exceptions/property.exception.ts +15 -0
- package/src/config/index.ts +10 -0
- package/src/config/metadata/config-metadata.registry.ts +76 -0
- package/src/config/metadata/decorators/config-section.decorator.ts +30 -0
- package/src/config/metadata/decorators/declare-property.decorator.ts +37 -0
- package/src/config/metadata/decorators/index.ts +4 -0
- package/src/config/metadata/decorators/inject-property.decorator.ts +29 -0
- package/src/config/metadata/decorators/property.decorator.ts +42 -0
- package/src/config/metadata/exceptions/duplicate-property.exception.ts +12 -0
- package/src/config/metadata/exceptions/duplicate-section.exception.ts +13 -0
- package/src/config/metadata/exceptions/duplicate-source.exception.ts +13 -0
- package/src/config/metadata/exceptions/index.ts +3 -0
- package/src/config/metadata/index.ts +2 -0
- package/src/config/parsers/array.parser.ts +40 -0
- package/src/config/parsers/boolean/bool.parser.ts +20 -0
- package/src/config/parsers/boolean/bool.spec.ts +4 -0
- package/src/config/parsers/boolean/index.ts +1 -0
- package/src/config/parsers/enum/enum.parser.ts +23 -0
- package/src/config/parsers/enum/enum.spec.ts +5 -0
- package/src/config/parsers/enum/index.ts +1 -0
- package/src/config/parsers/index.ts +10 -0
- package/src/config/parsers/int/index.ts +1 -0
- package/src/config/parsers/int/int.parser.ts +20 -0
- package/src/config/parsers/int/int.spec.ts +5 -0
- package/src/config/parsers/number/index.ts +1 -0
- package/src/config/parsers/number/number.parser.ts +23 -0
- package/src/config/parsers/number/number.spec.ts +5 -0
- package/src/config/parsers/path/fspath.parser.ts +65 -0
- package/src/config/parsers/path/index.ts +1 -0
- package/src/config/parsers/size/index.ts +1 -0
- package/src/config/parsers/size/size.parser.ts +22 -0
- package/src/config/parsers/size/size.spec.ts +4 -0
- package/src/config/parsers/string/index.ts +1 -0
- package/src/config/parsers/string/string.parser.ts +19 -0
- package/src/config/parsers/timespan/index.ts +1 -0
- package/src/config/parsers/timespan/timespan.parser.ts +27 -0
- package/src/config/parsers/timespan/timespan.spec.ts +4 -0
- package/src/config/parsers/url/index.ts +1 -0
- package/src/config/parsers/url/url.parser.ts +19 -0
- package/src/config/reload/config-reload.events.ts +43 -0
- package/src/config/reload/index.ts +1 -0
- package/src/config/sources/base/config-source.abstract.ts +90 -0
- package/src/config/sources/base/index.ts +2 -0
- package/src/config/sources/base/reloadable-config-source.abstract.ts +39 -0
- package/src/config/sources/config-source.decorator.ts +37 -0
- package/src/config/sources/exceptions/config-source-di.exception.ts +20 -0
- package/src/config/sources/exceptions/config-source.exception.ts +7 -0
- package/src/config/sources/exceptions/index.ts +2 -0
- package/src/config/sources/implementations/json-file.source.ts +29 -0
- package/src/config/sources/implementations/relodable-json-file.source.ts +39 -0
- package/src/config/sources/index.ts +3 -0
- package/src/config/types.ts +87 -0
- package/src/config/vars.class.ts +103 -0
- package/src/exceptions/base/bootstrap-exception.abstract.ts +20 -0
- package/src/exceptions/base/index.ts +3 -0
- package/src/exceptions/base/pipeline-exception.abstract.ts +29 -0
- package/src/exceptions/base/platform-exception.absract.ts +72 -0
- package/src/exceptions/implementations/bootstrap/double-init.exception.ts +21 -0
- package/src/exceptions/implementations/bootstrap/duplicate-protocol.exception.ts +19 -0
- package/src/exceptions/implementations/bootstrap/index.ts +8 -0
- package/src/exceptions/implementations/bootstrap/no-http.exception.ts +21 -0
- package/src/exceptions/implementations/bootstrap/no-init.exception.ts +21 -0
- package/src/exceptions/implementations/bootstrap/no-matching-transport.exception.ts +24 -0
- package/src/exceptions/implementations/bootstrap/sequence.exception.ts +16 -0
- package/src/exceptions/implementations/bootstrap/symbol-key-decoration.exception.ts +15 -0
- package/src/exceptions/implementations/bootstrap/unknown-bootstrap.exception.ts +11 -0
- package/src/exceptions/implementations/index.ts +2 -0
- package/src/exceptions/implementations/pipeline/authentication.exception.ts +20 -0
- package/src/exceptions/implementations/pipeline/conflict.exception.ts +21 -0
- package/src/exceptions/implementations/pipeline/duplicate-entity.exception.ts +20 -0
- package/src/exceptions/implementations/pipeline/index.ts +9 -0
- package/src/exceptions/implementations/pipeline/input.exception.ts +20 -0
- package/src/exceptions/implementations/pipeline/internal.exception.ts +20 -0
- package/src/exceptions/implementations/pipeline/not-allowed.exception.ts +20 -0
- package/src/exceptions/implementations/pipeline/not-found.exception.ts +20 -0
- package/src/exceptions/implementations/pipeline/timeout.exception.ts +19 -0
- package/src/exceptions/implementations/pipeline/validation.exception.ts +9 -0
- package/src/exceptions/index.ts +5 -0
- package/src/exceptions/metadata/decorators/exception.decorator.ts +10 -0
- package/src/exceptions/metadata/decorators/index.ts +2 -0
- package/src/exceptions/metadata/decorators/throws.decorator.ts +25 -0
- package/src/exceptions/metadata/exceptions.registry.ts +50 -0
- package/src/exceptions/metadata/index.ts +2 -0
- package/src/exceptions/types.ts +18 -0
- package/src/exceptions/validation/exception.ts +9 -0
- package/src/exceptions.handling/constants.ts +3 -0
- package/src/exceptions.handling/global-exceptions.config.ts +15 -0
- package/src/exceptions.handling/global-exceptions.filter.ts +81 -0
- package/src/exceptions.handling/global-exceptions.module.ts +67 -0
- package/src/exceptions.handling/index.ts +2 -0
- package/src/exceptions.handling/types.ts +88 -0
- package/src/health/exceptions/health-check.exception.ts +9 -0
- package/src/health/exceptions/index.ts +1 -0
- package/src/health/health.const.ts +2 -0
- package/src/health/health.module.ts +23 -0
- package/src/health/health.service.ts +125 -0
- package/src/health/helpers/check-result.class.ts +52 -0
- package/src/health/helpers/index.ts +1 -0
- package/src/health/index.ts +6 -0
- package/src/health/indicators.abstract/fs-access.indicator.ts +47 -0
- package/src/health/indicators.abstract/index.ts +2 -0
- package/src/health/indicators.abstract/ping.indicator.ts +36 -0
- package/src/health/metadata/index.ts +2 -0
- package/src/health/metadata/indicator.decorator.ts +25 -0
- package/src/health/metadata/indicators.registry.ts +38 -0
- package/src/health/types.ts +50 -0
- package/src/index.ts +32 -0
- package/src/logging/adapters/index.ts +1 -0
- package/src/logging/adapters/nest-logger.adapter.ts +32 -0
- package/src/logging/decorators/index.ts +1 -0
- package/src/logging/decorators/inject-logger.decorator.ts +15 -0
- package/src/logging/helpers.ts +5 -0
- package/src/logging/index.ts +4 -0
- package/src/logging/logging.config.ts +26 -0
- package/src/logging/logging.module.ts +48 -0
- package/src/logging/types.ts +3 -0
- package/src/manifest/manifest.ts +23 -0
- package/src/metrics/index.ts +4 -0
- package/src/metrics/metadata/decorators/index.ts +1 -0
- package/src/metrics/metadata/decorators/metric.decorator.ts +45 -0
- package/src/metrics/metadata/index.ts +2 -0
- package/src/metrics/metadata/metrics.registry.ts +35 -0
- package/src/metrics/metrics.config.ts +16 -0
- package/src/metrics/metrics.module.ts +100 -0
- package/src/metrics/types.ts +39 -0
- package/src/noop.http-adapter.ts +126 -0
- package/src/platform.context.ts +214 -0
- package/src/platform.module.ts +65 -0
- package/src/plugin/plugin.module.ts +24 -0
- package/src/tracing/auto-instrumentations.config.ts +35 -0
- package/src/tracing/constants.ts +6 -0
- package/src/tracing/decorators/index.ts +2 -0
- package/src/tracing/decorators/no-span.decorator.ts +10 -0
- package/src/tracing/decorators/span.decorator.ts +20 -0
- package/src/tracing/index.ts +1 -0
- package/src/tracing/services/index.ts +3 -0
- package/src/tracing/services/instrumentation.service.ts +145 -0
- package/src/tracing/services/metadata.scanner.ts +40 -0
- package/src/tracing/services/trace.injector.ts +147 -0
- package/src/tracing/tracing.config.ts +22 -0
- package/src/tracing/tracing.module.ts +120 -0
- package/src/transport/transport.module.ts +64 -0
- package/src/types/index.ts +4 -0
- package/src/types/metadata.ts +88 -0
- package/src/types/options.ts +83 -0
- package/src/types/plugins.ts +68 -0
- package/src/types/transports.ts +110 -0
- package/tsconfig.json +10 -0
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { DynamicModule } from '@nestjs/common';
|
|
2
|
+
import { Module } from '@nestjs/common';
|
|
3
|
+
import type { MiddlewareConsumer, NestModule } from '@nestjs/common/interfaces';
|
|
4
|
+
import type { Constructor } from '@rsdk/common';
|
|
5
|
+
|
|
6
|
+
import { PlatformPluginModule } from './plugin/plugin.module';
|
|
7
|
+
import { PlatformTransportModule } from './transport/transport.module';
|
|
8
|
+
import { AppMetadataModule } from './app-metadata';
|
|
9
|
+
import { PlatformConfigModule } from './config';
|
|
10
|
+
import { SequenceException } from './exceptions';
|
|
11
|
+
import { LoggingModule } from './logging';
|
|
12
|
+
import { TracingModule } from './tracing';
|
|
13
|
+
import type { PlatformExtendedOptions } from './types';
|
|
14
|
+
|
|
15
|
+
@Module({})
|
|
16
|
+
export class PlatformModule implements NestModule {
|
|
17
|
+
private static options: PlatformExtendedOptions;
|
|
18
|
+
|
|
19
|
+
static forRoot(options: PlatformExtendedOptions): DynamicModule {
|
|
20
|
+
if (this.options) {
|
|
21
|
+
throw new SequenceException(
|
|
22
|
+
"Can't call PlatformModule.setup() method twice",
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
this.options = options;
|
|
26
|
+
|
|
27
|
+
const imports: (DynamicModule | Constructor)[] = [
|
|
28
|
+
// Plugins
|
|
29
|
+
PlatformPluginModule.forOptions(options),
|
|
30
|
+
|
|
31
|
+
// Infrastructure
|
|
32
|
+
AppMetadataModule.forRoot(options),
|
|
33
|
+
LoggingModule.forRoot(),
|
|
34
|
+
PlatformConfigModule.forRoot(options),
|
|
35
|
+
TracingModule.forRoot({ appName: options.name, processing: 'simple' }),
|
|
36
|
+
];
|
|
37
|
+
|
|
38
|
+
// Adding transport module if needed
|
|
39
|
+
if (options.transports) {
|
|
40
|
+
imports.push(PlatformTransportModule.forOptions(options));
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// Adding application level modules
|
|
44
|
+
if (options.modules) {
|
|
45
|
+
imports.push(...options.modules);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return {
|
|
49
|
+
module: PlatformModule,
|
|
50
|
+
imports,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
configure(consumer: MiddlewareConsumer): void {
|
|
55
|
+
if (!PlatformModule.options) {
|
|
56
|
+
throw new SequenceException(
|
|
57
|
+
'Should call PlatformModule.setup() before configuring middleware!',
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
for (const plugin of PlatformModule.options.plugins || []) {
|
|
62
|
+
plugin?.configureMiddleware?.(consumer);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { DynamicModule } from '@nestjs/common';
|
|
2
|
+
import type { Constructor } from '@rsdk/common';
|
|
3
|
+
|
|
4
|
+
import type { PlatformExtendedOptions } from '../types';
|
|
5
|
+
|
|
6
|
+
export class PlatformPluginModule {
|
|
7
|
+
static forOptions(options: PlatformExtendedOptions): DynamicModule {
|
|
8
|
+
const modules: (DynamicModule | Constructor)[] = [];
|
|
9
|
+
|
|
10
|
+
// Adding additional modules (from plugins)
|
|
11
|
+
if (options.plugins) {
|
|
12
|
+
for (const plugin of options.plugins) {
|
|
13
|
+
if (plugin.modules) {
|
|
14
|
+
modules.push(...plugin.modules());
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return {
|
|
20
|
+
module: PlatformPluginModule,
|
|
21
|
+
imports: modules,
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { ClientRequest, IncomingMessage } from 'http';
|
|
2
|
+
|
|
3
|
+
import { getNodeAutoInstrumentations } from '@opentelemetry/auto-instrumentations-node';
|
|
4
|
+
|
|
5
|
+
export const autoInstumentationOptions = getNodeAutoInstrumentations({
|
|
6
|
+
'@opentelemetry/instrumentation-aws-sdk': {
|
|
7
|
+
responseHook: (span, { response }) => {
|
|
8
|
+
if (response.request.commandInput?.Bucket) {
|
|
9
|
+
span.setAttribute(
|
|
10
|
+
's3.bucket.name',
|
|
11
|
+
response.request.commandInput?.Bucket,
|
|
12
|
+
);
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
'@opentelemetry/instrumentation-graphql': {
|
|
17
|
+
allowValues: true,
|
|
18
|
+
},
|
|
19
|
+
'@opentelemetry/instrumentation-http': {
|
|
20
|
+
requestHook: (span, request) => {
|
|
21
|
+
if (request instanceof IncomingMessage) {
|
|
22
|
+
if (request.method && request.url) {
|
|
23
|
+
span.updateName(`${request.method} ${request.url}`);
|
|
24
|
+
}
|
|
25
|
+
} else if (request instanceof ClientRequest) {
|
|
26
|
+
if (request.req.method && request.req.url) {
|
|
27
|
+
span.updateName(`${request.req.method} ${request.req.url}`);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
'@opentelemetry/instrumentation-pg': {
|
|
33
|
+
enhancedDatabaseReporting: true,
|
|
34
|
+
},
|
|
35
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { SetMetadata } from '@nestjs/common';
|
|
2
|
+
|
|
3
|
+
import { Constants } from '../constants';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* TraceInjector will ignore classes and methods annotated with
|
|
7
|
+
* this decorator.
|
|
8
|
+
*/
|
|
9
|
+
export const NoSpan = (): MethodDecorator =>
|
|
10
|
+
SetMetadata(Constants.NO_SPAN_METADATA, true);
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { SymbolKeyDecorationException } from '../../exceptions';
|
|
2
|
+
import { TraceInjector } from '../services';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Explicitly adds instrumentation to method (don't work for classes!).
|
|
6
|
+
* Use for classes that you instantiate manually.
|
|
7
|
+
* NOTE: Is redundant for injectables and other nest.js stuff
|
|
8
|
+
*/
|
|
9
|
+
export const Span = (): MethodDecorator =>
|
|
10
|
+
function (
|
|
11
|
+
target: object,
|
|
12
|
+
methodName: string | symbol,
|
|
13
|
+
descriptor: TypedPropertyDescriptor<any>,
|
|
14
|
+
) {
|
|
15
|
+
if (typeof methodName === 'symbol') {
|
|
16
|
+
throw new SymbolKeyDecorationException();
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
TraceInjector.wrap(target, descriptor.value, descriptor);
|
|
20
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './tracing.module';
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { Injectable } from '@nestjs/common';
|
|
2
|
+
import {
|
|
3
|
+
EXCEPTION_FILTERS_METADATA,
|
|
4
|
+
GUARDS_METADATA,
|
|
5
|
+
INTERCEPTORS_METADATA,
|
|
6
|
+
PIPES_METADATA,
|
|
7
|
+
} from '@nestjs/common/constants';
|
|
8
|
+
import { APP_FILTER, APP_GUARD, APP_INTERCEPTOR, APP_PIPE } from '@nestjs/core';
|
|
9
|
+
import { ILogger } from '@rsdk/logging';
|
|
10
|
+
|
|
11
|
+
import { InjectLogger } from '../../logging';
|
|
12
|
+
|
|
13
|
+
import { ExtendedMetadataScanner } from './metadata.scanner';
|
|
14
|
+
import { TraceInjector } from './trace.injector';
|
|
15
|
+
|
|
16
|
+
const types = [
|
|
17
|
+
EXCEPTION_FILTERS_METADATA,
|
|
18
|
+
GUARDS_METADATA,
|
|
19
|
+
INTERCEPTORS_METADATA,
|
|
20
|
+
PIPES_METADATA,
|
|
21
|
+
] as const;
|
|
22
|
+
|
|
23
|
+
@Injectable()
|
|
24
|
+
export class InstrumentationService {
|
|
25
|
+
constructor(
|
|
26
|
+
@InjectLogger(InstrumentationService) private readonly logger: ILogger,
|
|
27
|
+
protected readonly scanner: ExtendedMetadataScanner,
|
|
28
|
+
) {}
|
|
29
|
+
|
|
30
|
+
public inject(): void {
|
|
31
|
+
/**
|
|
32
|
+
* Для каждого контроллера
|
|
33
|
+
*/
|
|
34
|
+
for (const controller of this.scanner.getControllers()) {
|
|
35
|
+
/**
|
|
36
|
+
* Перебираем методы контроллера и оборачиваем их.
|
|
37
|
+
*/
|
|
38
|
+
this.wrapMethods(controller.metatype.prototype);
|
|
39
|
+
|
|
40
|
+
this.wrapAugmentations(controller.metatype);
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Для каждого метода контроллера
|
|
44
|
+
*/
|
|
45
|
+
for (const name of this.scanner.getMethods(
|
|
46
|
+
controller.metatype.prototype,
|
|
47
|
+
)) {
|
|
48
|
+
/**
|
|
49
|
+
* Во вложенном цикле находим все гарды, интерцепторы, пайпы и фильтры,
|
|
50
|
+
* привязанные к методу.
|
|
51
|
+
* Уровни вложенности, как в цикле выше
|
|
52
|
+
*/
|
|
53
|
+
const method = controller.metatype.prototype[name];
|
|
54
|
+
|
|
55
|
+
this.wrapAugmentations(method);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Глобальные гарды, интерцепторы, пайпы и фильтры находятся
|
|
61
|
+
* в общем списке провайдеров по injection-токенам.
|
|
62
|
+
*/
|
|
63
|
+
for (const { metatype, token } of this.scanner.getProviders()) {
|
|
64
|
+
if (typeof token !== 'string') {
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (
|
|
69
|
+
token.includes(APP_GUARD) ||
|
|
70
|
+
token.includes(APP_PIPE) ||
|
|
71
|
+
token.includes(APP_INTERCEPTOR) ||
|
|
72
|
+
token.includes(APP_FILTER)
|
|
73
|
+
) {
|
|
74
|
+
this.wrapMethods(metatype.prototype);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Глобальные гарды, интерцепторы, пайпы и фильтры находятся
|
|
80
|
+
* в общем списке провайдеров по injection-токенам.
|
|
81
|
+
*/
|
|
82
|
+
for (const {
|
|
83
|
+
metatype: { name, prototype },
|
|
84
|
+
} of this.scanner.getProviders()) {
|
|
85
|
+
if (name.toLowerCase().endsWith('module')) {
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if (
|
|
90
|
+
name === 'ModuleRef' ||
|
|
91
|
+
name === 'Reflector' ||
|
|
92
|
+
name === 'OrphanedReferenceRegistry' ||
|
|
93
|
+
name === 'TypeFieldsAccessor' ||
|
|
94
|
+
name === 'TypeMapperSevice' ||
|
|
95
|
+
name === 'TypeDefinitionsStorage' ||
|
|
96
|
+
name === 'FileSystemHelper' ||
|
|
97
|
+
name === 'TypeDefinitionsGenerator' ||
|
|
98
|
+
name === 'GraphQLSchemaFactory' ||
|
|
99
|
+
name === 'AstDefinitionNodeFactory' ||
|
|
100
|
+
name === 'UnionDefinitionFactory' ||
|
|
101
|
+
name === 'SubscriptionTypeFactory' ||
|
|
102
|
+
name === 'RootTypeFactory' ||
|
|
103
|
+
name === 'ResolveTypeFactory' ||
|
|
104
|
+
name === 'QueryTypeFactory' ||
|
|
105
|
+
name === 'OrphanedTypesFactory' ||
|
|
106
|
+
name === 'OutputTypeFactory' ||
|
|
107
|
+
name === 'ObjectTypeDefinitionFactory' ||
|
|
108
|
+
name === 'MutationTypeFactory' ||
|
|
109
|
+
name === 'InterfaceDefinitionFactory' ||
|
|
110
|
+
name === 'InputTypeFactory' ||
|
|
111
|
+
name === 'ArgsFactory' ||
|
|
112
|
+
name === 'InputTypeDefinitionFactory' ||
|
|
113
|
+
name === 'EnumDefinitionFactory'
|
|
114
|
+
) {
|
|
115
|
+
continue;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
this.wrapMethods(prototype);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
private wrapAugmentations(metatype: object): void {
|
|
123
|
+
/**
|
|
124
|
+
* Перебираем во вложенных циклах все гарды, интерцепторы, пайпы и фильтры,
|
|
125
|
+
* повешенные на переданный прототип (metatype).
|
|
126
|
+
* 1-й уровень - типы сущностей: интерцепторы, гарды, пайпы, фильтры
|
|
127
|
+
* 2-й уровень - методы сущностей
|
|
128
|
+
*/
|
|
129
|
+
for (const metakey of types) {
|
|
130
|
+
for (const instance of Reflect.getMetadata(metakey, metatype) || []) {
|
|
131
|
+
this.wrapMethods(instance);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
private wrapMethods(obj: any): void {
|
|
137
|
+
const prototype = (obj as any).prototype ?? obj;
|
|
138
|
+
|
|
139
|
+
this.logger.trace(`Wrapping methods of ${prototype.constructor.name}...`);
|
|
140
|
+
|
|
141
|
+
for (const name of this.scanner.getMethods(prototype)) {
|
|
142
|
+
TraceInjector.wrap(prototype, prototype[name]);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Injectable } from '@nestjs/common';
|
|
2
|
+
import type {
|
|
3
|
+
Controller,
|
|
4
|
+
Injectable as Provider,
|
|
5
|
+
} from '@nestjs/common/interfaces';
|
|
6
|
+
import { MetadataScanner, ModulesContainer } from '@nestjs/core';
|
|
7
|
+
import type { InstanceWrapper } from '@nestjs/core/injector/instance-wrapper';
|
|
8
|
+
|
|
9
|
+
@Injectable()
|
|
10
|
+
export class ExtendedMetadataScanner {
|
|
11
|
+
private readonly scanner = new MetadataScanner();
|
|
12
|
+
|
|
13
|
+
constructor(private readonly modules: ModulesContainer) {}
|
|
14
|
+
|
|
15
|
+
*getControllers(): Generator<InstanceWrapper<Controller>> {
|
|
16
|
+
for (const module of this.modules.values()) {
|
|
17
|
+
for (const controller of module.controllers.values()) {
|
|
18
|
+
if (controller && controller.metatype?.prototype) {
|
|
19
|
+
yield controller;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
*getProviders(): Generator<InstanceWrapper<Provider>> {
|
|
26
|
+
for (const module of this.modules.values()) {
|
|
27
|
+
for (const provider of module.providers.values()) {
|
|
28
|
+
if (provider && provider.metatype?.prototype) {
|
|
29
|
+
yield provider;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
*getMethods(prototype: any): Generator<string> {
|
|
36
|
+
for (const name of this.scanner.getAllFilteredMethodNames(prototype)) {
|
|
37
|
+
yield name;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import assert from 'assert';
|
|
2
|
+
|
|
3
|
+
import type { AttributeValue, Span } from '@opentelemetry/api';
|
|
4
|
+
import { SpanStatusCode, trace } from '@opentelemetry/api';
|
|
5
|
+
import type { ErrorLike } from '@rsdk/common';
|
|
6
|
+
import { isPrimitive, isRecord, normalizer } from '@rsdk/common';
|
|
7
|
+
import { redecorate } from '@rsdk/decorators';
|
|
8
|
+
import { LoggerFactory } from '@rsdk/logging';
|
|
9
|
+
|
|
10
|
+
import { Constants, MAX_BYTES } from '../constants';
|
|
11
|
+
|
|
12
|
+
const logger = LoggerFactory.create('TraceInjector');
|
|
13
|
+
|
|
14
|
+
export class TraceInjector {
|
|
15
|
+
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
16
|
+
static wrap(
|
|
17
|
+
cls: any,
|
|
18
|
+
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
19
|
+
original: Function,
|
|
20
|
+
descriptor?: TypedPropertyDescriptor<any>,
|
|
21
|
+
): void {
|
|
22
|
+
/**
|
|
23
|
+
* Означает, что данный метод уже обёрнут
|
|
24
|
+
*/
|
|
25
|
+
if (TraceInjector.isWrapped(original) || TraceInjector.nowSpan(original)) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
logger.trace(`Wrapping method: ${cls.constructor.name}.${original.name}()`);
|
|
30
|
+
|
|
31
|
+
const spanName = TraceInjector.createSpanName(cls, original.name);
|
|
32
|
+
const wrapped = TraceInjector.createWrapper(original, spanName);
|
|
33
|
+
|
|
34
|
+
redecorate(original, wrapped);
|
|
35
|
+
|
|
36
|
+
if (descriptor) {
|
|
37
|
+
descriptor.value = wrapped;
|
|
38
|
+
} else {
|
|
39
|
+
cls[original.name] = wrapped;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Отмечает метод, как обёрнутый (чтобы избежать повторного оборачивания)
|
|
44
|
+
*/
|
|
45
|
+
TraceInjector.setWrapped(wrapped);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// TODO: Maybe move to standalone function, because it's
|
|
49
|
+
// the only public function except for the main one
|
|
50
|
+
static toAttribute(data: unknown): AttributeValue {
|
|
51
|
+
if (isPrimitive(data)) {
|
|
52
|
+
return data;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (isRecord(data) || Array.isArray(data)) {
|
|
56
|
+
const serialized = JSON.stringify(normalizer()(data));
|
|
57
|
+
|
|
58
|
+
return serialized.length <= MAX_BYTES
|
|
59
|
+
? serialized
|
|
60
|
+
: `data exceeds limit of ${MAX_BYTES} bytes`;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return 'data is undefined';
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
private static createWrapper(original: any, spanName: string): any {
|
|
67
|
+
return {
|
|
68
|
+
[original.name](...args: any[]): any {
|
|
69
|
+
const tracer = trace.getTracer('@rsdk/open-telemetry', '1.0.0');
|
|
70
|
+
|
|
71
|
+
return tracer.startActiveSpan(spanName, (span) => {
|
|
72
|
+
try {
|
|
73
|
+
logger.trace(`Wrapped function invoked: ${original.name}`);
|
|
74
|
+
|
|
75
|
+
const result = original.apply(this, args);
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* If function returns promise:
|
|
79
|
+
* - errors won't be caught with try-catch
|
|
80
|
+
* - enriching span should be don when promise is resolved
|
|
81
|
+
*
|
|
82
|
+
* That's why this extra branch exists
|
|
83
|
+
*/
|
|
84
|
+
if (result instanceof Promise) {
|
|
85
|
+
return result
|
|
86
|
+
.then((result: unknown) => TraceInjector.enrich(span, result))
|
|
87
|
+
.catch((error: unknown) =>
|
|
88
|
+
TraceInjector.recordAndRethrow(error, span),
|
|
89
|
+
)
|
|
90
|
+
.finally(() => span.end());
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
TraceInjector.enrich(span, result);
|
|
94
|
+
span.end();
|
|
95
|
+
|
|
96
|
+
return result;
|
|
97
|
+
} catch (error) {
|
|
98
|
+
TraceInjector.recordAndRethrow(error, span);
|
|
99
|
+
span.end();
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
},
|
|
103
|
+
}[original.name];
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
private static createSpanName(cls: object, methodName: string): string {
|
|
107
|
+
return `${cls.constructor.name} -> ${methodName}`;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
private static isWrapped(prototype: object): boolean {
|
|
111
|
+
assert.ok(prototype);
|
|
112
|
+
|
|
113
|
+
return Reflect.hasMetadata(Constants.TRACE_METADATA_ACTIVE, prototype);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
private static nowSpan(prototype: object): boolean {
|
|
117
|
+
assert.ok(prototype);
|
|
118
|
+
|
|
119
|
+
return Reflect.hasMetadata(Constants.NO_SPAN_METADATA, prototype);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
private static setWrapped(prototype: object): void {
|
|
123
|
+
assert.ok(prototype);
|
|
124
|
+
|
|
125
|
+
// Value doesn't matter
|
|
126
|
+
const NOOP = 1;
|
|
127
|
+
|
|
128
|
+
Reflect.defineMetadata(Constants.TRACE_METADATA_ACTIVE, NOOP, prototype);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
private static recordAndRethrow(error: unknown, span: Span): void {
|
|
132
|
+
span.recordException(error as ErrorLike);
|
|
133
|
+
span.setStatus({
|
|
134
|
+
code: SpanStatusCode.ERROR,
|
|
135
|
+
message: (error as ErrorLike).message,
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
throw error;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
private static enrich(span: Span, data: unknown): unknown {
|
|
142
|
+
span.setAttribute('response', TraceInjector.toAttribute(data));
|
|
143
|
+
span.setStatus({ code: SpanStatusCode.OK });
|
|
144
|
+
|
|
145
|
+
return data;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BoolParser,
|
|
3
|
+
Config,
|
|
4
|
+
ConfigSection,
|
|
5
|
+
Property,
|
|
6
|
+
UrlParser,
|
|
7
|
+
} from '../config';
|
|
8
|
+
|
|
9
|
+
@ConfigSection()
|
|
10
|
+
export class TracingModuleConfig extends Config {
|
|
11
|
+
@Property('TRACING_ENABLED', new BoolParser(), {
|
|
12
|
+
defaultValue: false,
|
|
13
|
+
description: 'Enable application tracing',
|
|
14
|
+
})
|
|
15
|
+
enabled!: boolean;
|
|
16
|
+
|
|
17
|
+
@Property('TRACING_COLLECTOR_URL', new UrlParser(), {
|
|
18
|
+
defaultValue: new URL('http://localhost:4318/v1/traces'),
|
|
19
|
+
description: 'Url to jaeger/zipkin/otlp collector etc.',
|
|
20
|
+
})
|
|
21
|
+
collectorUrl!: URL;
|
|
22
|
+
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import type { DynamicModule, Provider } from '@nestjs/common';
|
|
2
|
+
import { Module } from '@nestjs/common';
|
|
3
|
+
import { context, trace } from '@opentelemetry/api';
|
|
4
|
+
import { AsyncLocalStorageContextManager } from '@opentelemetry/context-async-hooks';
|
|
5
|
+
import { CompositePropagator } from '@opentelemetry/core';
|
|
6
|
+
import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http';
|
|
7
|
+
import { B3InjectEncoding, B3Propagator } from '@opentelemetry/propagator-b3';
|
|
8
|
+
import { Resource } from '@opentelemetry/resources';
|
|
9
|
+
import { NodeSDK } from '@opentelemetry/sdk-node';
|
|
10
|
+
import type { SpanExporter } from '@opentelemetry/sdk-trace-base';
|
|
11
|
+
import {
|
|
12
|
+
BatchSpanProcessor,
|
|
13
|
+
SimpleSpanProcessor,
|
|
14
|
+
} from '@opentelemetry/sdk-trace-base';
|
|
15
|
+
import { SemanticResourceAttributes } from '@opentelemetry/semantic-conventions';
|
|
16
|
+
import { ILogger, LoggerFactory } from '@rsdk/logging';
|
|
17
|
+
|
|
18
|
+
import { PlatformConfigModule } from '../config';
|
|
19
|
+
import { InjectLogger } from '../logging';
|
|
20
|
+
|
|
21
|
+
import { InstrumentationService } from './services/instrumentation.service';
|
|
22
|
+
import { ExtendedMetadataScanner } from './services/metadata.scanner';
|
|
23
|
+
import { autoInstumentationOptions } from './auto-instrumentations.config';
|
|
24
|
+
import { TracingModuleConfig } from './tracing.config';
|
|
25
|
+
|
|
26
|
+
export interface TracingModuleOptions {
|
|
27
|
+
appName: string;
|
|
28
|
+
processing: 'simple' | 'batch';
|
|
29
|
+
exporter?: SpanExporter;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
@Module({})
|
|
33
|
+
export class TracingModule {
|
|
34
|
+
constructor(
|
|
35
|
+
@InjectLogger(TracingModule) private readonly logger: ILogger,
|
|
36
|
+
private readonly instrumentations: InstrumentationService,
|
|
37
|
+
private readonly sdk: NodeSDK,
|
|
38
|
+
private readonly config: TracingModuleConfig,
|
|
39
|
+
) {}
|
|
40
|
+
|
|
41
|
+
static forRoot(options: TracingModuleOptions): DynamicModule {
|
|
42
|
+
return {
|
|
43
|
+
module: TracingModule,
|
|
44
|
+
|
|
45
|
+
imports: [PlatformConfigModule.forFeature(TracingModuleConfig)],
|
|
46
|
+
providers: [
|
|
47
|
+
ExtendedMetadataScanner,
|
|
48
|
+
InstrumentationService,
|
|
49
|
+
this.createSDKProvider(options),
|
|
50
|
+
],
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
private static createSDKProvider(options: TracingModuleOptions): Provider {
|
|
55
|
+
return {
|
|
56
|
+
provide: NodeSDK,
|
|
57
|
+
|
|
58
|
+
inject: [TracingModuleConfig],
|
|
59
|
+
useFactory: (config: TracingModuleConfig): NodeSDK => {
|
|
60
|
+
const exporter =
|
|
61
|
+
options.exporter ||
|
|
62
|
+
new OTLPTraceExporter({
|
|
63
|
+
url: config.collectorUrl?.toString(),
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
const processor =
|
|
67
|
+
options.processing === 'simple'
|
|
68
|
+
? new SimpleSpanProcessor(exporter)
|
|
69
|
+
: new BatchSpanProcessor(exporter);
|
|
70
|
+
|
|
71
|
+
return new NodeSDK({
|
|
72
|
+
autoDetectResources: true,
|
|
73
|
+
contextManager: new AsyncLocalStorageContextManager(),
|
|
74
|
+
instrumentations: [autoInstumentationOptions],
|
|
75
|
+
resource: new Resource({
|
|
76
|
+
[SemanticResourceAttributes.SERVICE_NAME]: options.appName,
|
|
77
|
+
}),
|
|
78
|
+
spanProcessor: processor,
|
|
79
|
+
textMapPropagator: new CompositePropagator({
|
|
80
|
+
propagators: [
|
|
81
|
+
new B3Propagator(),
|
|
82
|
+
new B3Propagator({
|
|
83
|
+
injectEncoding: B3InjectEncoding.MULTI_HEADER,
|
|
84
|
+
}),
|
|
85
|
+
],
|
|
86
|
+
}),
|
|
87
|
+
});
|
|
88
|
+
},
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// Можно добавить включение и выключение при изменении конфига.
|
|
93
|
+
async onModuleInit(): Promise<void> {
|
|
94
|
+
if (!this.config.enabled) {
|
|
95
|
+
this.logger.info('Tracing is disabled');
|
|
96
|
+
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
this.logger.info('Tracing is enabled');
|
|
101
|
+
|
|
102
|
+
this.logger.debug('Starting Open Telemetry SDK...');
|
|
103
|
+
await this.sdk.start();
|
|
104
|
+
|
|
105
|
+
this.logger.debug('Instrumenting nest.js entities...');
|
|
106
|
+
this.instrumentations.inject();
|
|
107
|
+
|
|
108
|
+
this.logger.debug('Attaching log messages to spans...');
|
|
109
|
+
LoggerFactory.onMessage((level, msg) => {
|
|
110
|
+
const span = trace.getSpan(context.active());
|
|
111
|
+
|
|
112
|
+
span?.addEvent('log', { ...msg, level });
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
async beforeApplicationShutdown(): Promise<void> {
|
|
117
|
+
this.logger.info('Shutting down Open Telemetry SDK...');
|
|
118
|
+
await this.sdk.shutdown();
|
|
119
|
+
}
|
|
120
|
+
}
|