@opentelemetry/resources
Advanced tools
@@ -1,8 +0,8 @@ | ||
| export { ResourceDetectionConfig } from './config'; | ||
| export type { ResourceDetectionConfig } from './config'; | ||
| export { detectResources } from './detect-resources'; | ||
| export { envDetector, hostDetector, osDetector, processDetector, serviceInstanceIdDetector, } from './detectors'; | ||
| export { Resource } from './Resource'; | ||
| export type { Resource } from './Resource'; | ||
| export { resourceFromAttributes, defaultResource, emptyResource, } from './ResourceImpl'; | ||
| export { defaultServiceName } from './platform'; | ||
| export { ResourceDetector, DetectedResource, DetectedResourceAttributes, RawResourceAttribute, MaybePromise, } from './types'; | ||
| export type { ResourceDetector, DetectedResource, DetectedResourceAttributes, RawResourceAttribute, MaybePromise, } from './types'; | ||
| //# sourceMappingURL=index.d.ts.map |
@@ -26,2 +26,6 @@ import { Attributes } from '@opentelemetry/api'; | ||
| /** | ||
| * @returns the Resource's schema URL or undefined if not set. | ||
| */ | ||
| readonly schemaUrl?: string; | ||
| /** | ||
| * Returns a promise that will never be rejected. Resolves when all async attributes have finished being added to | ||
@@ -28,0 +32,0 @@ * this Resource's attributes. This is useful in exporters to block until resource detection |
| import { Resource } from './Resource'; | ||
| import { DetectedResource, DetectedResourceAttributes } from './types'; | ||
| export declare function resourceFromAttributes(attributes: DetectedResourceAttributes): Resource; | ||
| export declare function resourceFromDetectedResource(detectedResource: DetectedResource): Resource; | ||
| import { DetectedResource, DetectedResourceAttributes, ResourceOptions } from './types'; | ||
| export declare function resourceFromAttributes(attributes: DetectedResourceAttributes, options?: ResourceOptions): Resource; | ||
| export declare function resourceFromDetectedResource(detectedResource: DetectedResource, options?: ResourceOptions): Resource; | ||
| export declare function emptyResource(): Resource; | ||
| export declare function defaultResource(): Resource; | ||
| //# sourceMappingURL=ResourceImpl.d.ts.map |
@@ -24,5 +24,6 @@ /* | ||
| _asyncAttributesPending = false; | ||
| _schemaUrl; | ||
| _memoizedAttributes; | ||
| static FromAttributeList(attributes) { | ||
| const res = new ResourceImpl({}); | ||
| static FromAttributeList(attributes, options) { | ||
| const res = new ResourceImpl({}, options); | ||
| res._rawAttributes = guardedRawAttributes(attributes); | ||
@@ -39,3 +40,3 @@ res._asyncAttributesPending = | ||
| */ | ||
| resource) { | ||
| resource, options) { | ||
| const attributes = resource.attributes ?? {}; | ||
@@ -50,2 +51,3 @@ this._rawAttributes = Object.entries(attributes).map(([k, v]) => { | ||
| this._rawAttributes = guardedRawAttributes(this._rawAttributes); | ||
| this._schemaUrl = validateSchemaUrl(options?.schemaUrl); | ||
| } | ||
@@ -91,2 +93,5 @@ get asyncAttributesPending() { | ||
| } | ||
| get schemaUrl() { | ||
| return this._schemaUrl; | ||
| } | ||
| merge(resource) { | ||
@@ -97,13 +102,14 @@ if (resource == null) | ||
| // Spec states incoming attributes override existing attributes | ||
| return ResourceImpl.FromAttributeList([ | ||
| ...resource.getRawAttributes(), | ||
| ...this.getRawAttributes(), | ||
| ]); | ||
| const mergedSchemaUrl = mergeSchemaUrl(this, resource); | ||
| const mergedOptions = mergedSchemaUrl | ||
| ? { schemaUrl: mergedSchemaUrl } | ||
| : undefined; | ||
| return ResourceImpl.FromAttributeList([...resource.getRawAttributes(), ...this.getRawAttributes()], mergedOptions); | ||
| } | ||
| } | ||
| export function resourceFromAttributes(attributes) { | ||
| return ResourceImpl.FromAttributeList(Object.entries(attributes)); | ||
| export function resourceFromAttributes(attributes, options) { | ||
| return ResourceImpl.FromAttributeList(Object.entries(attributes), options); | ||
| } | ||
| export function resourceFromDetectedResource(detectedResource) { | ||
| return new ResourceImpl(detectedResource); | ||
| export function resourceFromDetectedResource(detectedResource, options) { | ||
| return new ResourceImpl(detectedResource, options); | ||
| } | ||
@@ -135,2 +141,26 @@ export function emptyResource() { | ||
| } | ||
| function validateSchemaUrl(schemaUrl) { | ||
| if (typeof schemaUrl === 'string' || schemaUrl === undefined) { | ||
| return schemaUrl; | ||
| } | ||
| diag.warn('Schema URL must be string or undefined, got %s. Schema URL will be ignored.', schemaUrl); | ||
| return undefined; | ||
| } | ||
| function mergeSchemaUrl(old, updating) { | ||
| const oldSchemaUrl = old?.schemaUrl; | ||
| const updatingSchemaUrl = updating?.schemaUrl; | ||
| const isOldEmpty = oldSchemaUrl === undefined || oldSchemaUrl === ''; | ||
| const isUpdatingEmpty = updatingSchemaUrl === undefined || updatingSchemaUrl === ''; | ||
| if (isOldEmpty) { | ||
| return updatingSchemaUrl; | ||
| } | ||
| if (isUpdatingEmpty) { | ||
| return oldSchemaUrl; | ||
| } | ||
| if (oldSchemaUrl === updatingSchemaUrl) { | ||
| return oldSchemaUrl; | ||
| } | ||
| diag.warn('Schema URL merge conflict: old resource has "%s", updating resource has "%s". Resulting resource will have undefined Schema URL.', oldSchemaUrl, updatingSchemaUrl); | ||
| return undefined; | ||
| } | ||
| //# sourceMappingURL=ResourceImpl.js.map |
@@ -37,3 +37,9 @@ import { AttributeValue } from '@opentelemetry/api'; | ||
| ]; | ||
| /** | ||
| * Options for creating a {@link Resource}. | ||
| */ | ||
| export type ResourceOptions = { | ||
| schemaUrl?: string; | ||
| }; | ||
| export {}; | ||
| //# sourceMappingURL=types.d.ts.map |
@@ -1,2 +0,2 @@ | ||
| export declare const VERSION = "2.0.1"; | ||
| export declare const VERSION = "2.1.0"; | ||
| //# sourceMappingURL=version.d.ts.map |
@@ -17,3 +17,3 @@ /* | ||
| // this is autogenerated file, see scripts/version-update.js | ||
| export const VERSION = '2.0.1'; | ||
| export const VERSION = '2.1.0'; | ||
| //# sourceMappingURL=version.js.map |
@@ -1,8 +0,8 @@ | ||
| export { ResourceDetectionConfig } from './config'; | ||
| export type { ResourceDetectionConfig } from './config'; | ||
| export { detectResources } from './detect-resources'; | ||
| export { envDetector, hostDetector, osDetector, processDetector, serviceInstanceIdDetector, } from './detectors'; | ||
| export { Resource } from './Resource'; | ||
| export type { Resource } from './Resource'; | ||
| export { resourceFromAttributes, defaultResource, emptyResource, } from './ResourceImpl'; | ||
| export { defaultServiceName } from './platform'; | ||
| export { ResourceDetector, DetectedResource, DetectedResourceAttributes, RawResourceAttribute, MaybePromise, } from './types'; | ||
| export type { ResourceDetector, DetectedResource, DetectedResourceAttributes, RawResourceAttribute, MaybePromise, } from './types'; | ||
| //# sourceMappingURL=index.d.ts.map |
@@ -26,2 +26,6 @@ import { Attributes } from '@opentelemetry/api'; | ||
| /** | ||
| * @returns the Resource's schema URL or undefined if not set. | ||
| */ | ||
| readonly schemaUrl?: string; | ||
| /** | ||
| * Returns a promise that will never be rejected. Resolves when all async attributes have finished being added to | ||
@@ -28,0 +32,0 @@ * this Resource's attributes. This is useful in exporters to block until resource detection |
| import { Resource } from './Resource'; | ||
| import { DetectedResource, DetectedResourceAttributes } from './types'; | ||
| export declare function resourceFromAttributes(attributes: DetectedResourceAttributes): Resource; | ||
| export declare function resourceFromDetectedResource(detectedResource: DetectedResource): Resource; | ||
| import { DetectedResource, DetectedResourceAttributes, ResourceOptions } from './types'; | ||
| export declare function resourceFromAttributes(attributes: DetectedResourceAttributes, options?: ResourceOptions): Resource; | ||
| export declare function resourceFromDetectedResource(detectedResource: DetectedResource, options?: ResourceOptions): Resource; | ||
| export declare function emptyResource(): Resource; | ||
| export declare function defaultResource(): Resource; | ||
| //# sourceMappingURL=ResourceImpl.d.ts.map |
@@ -24,5 +24,6 @@ /* | ||
| _asyncAttributesPending = false; | ||
| _schemaUrl; | ||
| _memoizedAttributes; | ||
| static FromAttributeList(attributes) { | ||
| const res = new ResourceImpl({}); | ||
| static FromAttributeList(attributes, options) { | ||
| const res = new ResourceImpl({}, options); | ||
| res._rawAttributes = guardedRawAttributes(attributes); | ||
@@ -39,3 +40,3 @@ res._asyncAttributesPending = | ||
| */ | ||
| resource) { | ||
| resource, options) { | ||
| const attributes = resource.attributes ?? {}; | ||
@@ -50,2 +51,3 @@ this._rawAttributes = Object.entries(attributes).map(([k, v]) => { | ||
| this._rawAttributes = guardedRawAttributes(this._rawAttributes); | ||
| this._schemaUrl = validateSchemaUrl(options?.schemaUrl); | ||
| } | ||
@@ -91,2 +93,5 @@ get asyncAttributesPending() { | ||
| } | ||
| get schemaUrl() { | ||
| return this._schemaUrl; | ||
| } | ||
| merge(resource) { | ||
@@ -97,13 +102,14 @@ if (resource == null) | ||
| // Spec states incoming attributes override existing attributes | ||
| return ResourceImpl.FromAttributeList([ | ||
| ...resource.getRawAttributes(), | ||
| ...this.getRawAttributes(), | ||
| ]); | ||
| const mergedSchemaUrl = mergeSchemaUrl(this, resource); | ||
| const mergedOptions = mergedSchemaUrl | ||
| ? { schemaUrl: mergedSchemaUrl } | ||
| : undefined; | ||
| return ResourceImpl.FromAttributeList([...resource.getRawAttributes(), ...this.getRawAttributes()], mergedOptions); | ||
| } | ||
| } | ||
| export function resourceFromAttributes(attributes) { | ||
| return ResourceImpl.FromAttributeList(Object.entries(attributes)); | ||
| export function resourceFromAttributes(attributes, options) { | ||
| return ResourceImpl.FromAttributeList(Object.entries(attributes), options); | ||
| } | ||
| export function resourceFromDetectedResource(detectedResource) { | ||
| return new ResourceImpl(detectedResource); | ||
| export function resourceFromDetectedResource(detectedResource, options) { | ||
| return new ResourceImpl(detectedResource, options); | ||
| } | ||
@@ -135,2 +141,26 @@ export function emptyResource() { | ||
| } | ||
| function validateSchemaUrl(schemaUrl) { | ||
| if (typeof schemaUrl === 'string' || schemaUrl === undefined) { | ||
| return schemaUrl; | ||
| } | ||
| diag.warn('Schema URL must be string or undefined, got %s. Schema URL will be ignored.', schemaUrl); | ||
| return undefined; | ||
| } | ||
| function mergeSchemaUrl(old, updating) { | ||
| const oldSchemaUrl = old?.schemaUrl; | ||
| const updatingSchemaUrl = updating?.schemaUrl; | ||
| const isOldEmpty = oldSchemaUrl === undefined || oldSchemaUrl === ''; | ||
| const isUpdatingEmpty = updatingSchemaUrl === undefined || updatingSchemaUrl === ''; | ||
| if (isOldEmpty) { | ||
| return updatingSchemaUrl; | ||
| } | ||
| if (isUpdatingEmpty) { | ||
| return oldSchemaUrl; | ||
| } | ||
| if (oldSchemaUrl === updatingSchemaUrl) { | ||
| return oldSchemaUrl; | ||
| } | ||
| diag.warn('Schema URL merge conflict: old resource has "%s", updating resource has "%s". Resulting resource will have undefined Schema URL.', oldSchemaUrl, updatingSchemaUrl); | ||
| return undefined; | ||
| } | ||
| //# sourceMappingURL=ResourceImpl.js.map |
@@ -37,3 +37,9 @@ import { AttributeValue } from '@opentelemetry/api'; | ||
| ]; | ||
| /** | ||
| * Options for creating a {@link Resource}. | ||
| */ | ||
| export type ResourceOptions = { | ||
| schemaUrl?: string; | ||
| }; | ||
| export {}; | ||
| //# sourceMappingURL=types.d.ts.map |
@@ -1,2 +0,2 @@ | ||
| export declare const VERSION = "2.0.1"; | ||
| export declare const VERSION = "2.1.0"; | ||
| //# sourceMappingURL=version.d.ts.map |
@@ -17,3 +17,3 @@ /* | ||
| // this is autogenerated file, see scripts/version-update.js | ||
| export const VERSION = '2.0.1'; | ||
| export const VERSION = '2.1.0'; | ||
| //# sourceMappingURL=version.js.map |
@@ -1,8 +0,8 @@ | ||
| export { ResourceDetectionConfig } from './config'; | ||
| export type { ResourceDetectionConfig } from './config'; | ||
| export { detectResources } from './detect-resources'; | ||
| export { envDetector, hostDetector, osDetector, processDetector, serviceInstanceIdDetector, } from './detectors'; | ||
| export { Resource } from './Resource'; | ||
| export type { Resource } from './Resource'; | ||
| export { resourceFromAttributes, defaultResource, emptyResource, } from './ResourceImpl'; | ||
| export { defaultServiceName } from './platform'; | ||
| export { ResourceDetector, DetectedResource, DetectedResourceAttributes, RawResourceAttribute, MaybePromise, } from './types'; | ||
| export type { ResourceDetector, DetectedResource, DetectedResourceAttributes, RawResourceAttribute, MaybePromise, } from './types'; | ||
| //# sourceMappingURL=index.d.ts.map |
@@ -26,2 +26,6 @@ import { Attributes } from '@opentelemetry/api'; | ||
| /** | ||
| * @returns the Resource's schema URL or undefined if not set. | ||
| */ | ||
| readonly schemaUrl?: string; | ||
| /** | ||
| * Returns a promise that will never be rejected. Resolves when all async attributes have finished being added to | ||
@@ -28,0 +32,0 @@ * this Resource's attributes. This is useful in exporters to block until resource detection |
| import { Resource } from './Resource'; | ||
| import { DetectedResource, DetectedResourceAttributes } from './types'; | ||
| export declare function resourceFromAttributes(attributes: DetectedResourceAttributes): Resource; | ||
| export declare function resourceFromDetectedResource(detectedResource: DetectedResource): Resource; | ||
| import { DetectedResource, DetectedResourceAttributes, ResourceOptions } from './types'; | ||
| export declare function resourceFromAttributes(attributes: DetectedResourceAttributes, options?: ResourceOptions): Resource; | ||
| export declare function resourceFromDetectedResource(detectedResource: DetectedResource, options?: ResourceOptions): Resource; | ||
| export declare function emptyResource(): Resource; | ||
| export declare function defaultResource(): Resource; | ||
| //# sourceMappingURL=ResourceImpl.d.ts.map |
@@ -27,5 +27,6 @@ "use strict"; | ||
| _asyncAttributesPending = false; | ||
| _schemaUrl; | ||
| _memoizedAttributes; | ||
| static FromAttributeList(attributes) { | ||
| const res = new ResourceImpl({}); | ||
| static FromAttributeList(attributes, options) { | ||
| const res = new ResourceImpl({}, options); | ||
| res._rawAttributes = guardedRawAttributes(attributes); | ||
@@ -42,3 +43,3 @@ res._asyncAttributesPending = | ||
| */ | ||
| resource) { | ||
| resource, options) { | ||
| const attributes = resource.attributes ?? {}; | ||
@@ -53,2 +54,3 @@ this._rawAttributes = Object.entries(attributes).map(([k, v]) => { | ||
| this._rawAttributes = guardedRawAttributes(this._rawAttributes); | ||
| this._schemaUrl = validateSchemaUrl(options?.schemaUrl); | ||
| } | ||
@@ -94,2 +96,5 @@ get asyncAttributesPending() { | ||
| } | ||
| get schemaUrl() { | ||
| return this._schemaUrl; | ||
| } | ||
| merge(resource) { | ||
@@ -100,14 +105,15 @@ if (resource == null) | ||
| // Spec states incoming attributes override existing attributes | ||
| return ResourceImpl.FromAttributeList([ | ||
| ...resource.getRawAttributes(), | ||
| ...this.getRawAttributes(), | ||
| ]); | ||
| const mergedSchemaUrl = mergeSchemaUrl(this, resource); | ||
| const mergedOptions = mergedSchemaUrl | ||
| ? { schemaUrl: mergedSchemaUrl } | ||
| : undefined; | ||
| return ResourceImpl.FromAttributeList([...resource.getRawAttributes(), ...this.getRawAttributes()], mergedOptions); | ||
| } | ||
| } | ||
| function resourceFromAttributes(attributes) { | ||
| return ResourceImpl.FromAttributeList(Object.entries(attributes)); | ||
| function resourceFromAttributes(attributes, options) { | ||
| return ResourceImpl.FromAttributeList(Object.entries(attributes), options); | ||
| } | ||
| exports.resourceFromAttributes = resourceFromAttributes; | ||
| function resourceFromDetectedResource(detectedResource) { | ||
| return new ResourceImpl(detectedResource); | ||
| function resourceFromDetectedResource(detectedResource, options) { | ||
| return new ResourceImpl(detectedResource, options); | ||
| } | ||
@@ -142,2 +148,26 @@ exports.resourceFromDetectedResource = resourceFromDetectedResource; | ||
| } | ||
| function validateSchemaUrl(schemaUrl) { | ||
| if (typeof schemaUrl === 'string' || schemaUrl === undefined) { | ||
| return schemaUrl; | ||
| } | ||
| api_1.diag.warn('Schema URL must be string or undefined, got %s. Schema URL will be ignored.', schemaUrl); | ||
| return undefined; | ||
| } | ||
| function mergeSchemaUrl(old, updating) { | ||
| const oldSchemaUrl = old?.schemaUrl; | ||
| const updatingSchemaUrl = updating?.schemaUrl; | ||
| const isOldEmpty = oldSchemaUrl === undefined || oldSchemaUrl === ''; | ||
| const isUpdatingEmpty = updatingSchemaUrl === undefined || updatingSchemaUrl === ''; | ||
| if (isOldEmpty) { | ||
| return updatingSchemaUrl; | ||
| } | ||
| if (isUpdatingEmpty) { | ||
| return oldSchemaUrl; | ||
| } | ||
| if (oldSchemaUrl === updatingSchemaUrl) { | ||
| return oldSchemaUrl; | ||
| } | ||
| api_1.diag.warn('Schema URL merge conflict: old resource has "%s", updating resource has "%s". Resulting resource will have undefined Schema URL.', oldSchemaUrl, updatingSchemaUrl); | ||
| return undefined; | ||
| } | ||
| //# sourceMappingURL=ResourceImpl.js.map |
@@ -37,3 +37,9 @@ import { AttributeValue } from '@opentelemetry/api'; | ||
| ]; | ||
| /** | ||
| * Options for creating a {@link Resource}. | ||
| */ | ||
| export type ResourceOptions = { | ||
| schemaUrl?: string; | ||
| }; | ||
| export {}; | ||
| //# sourceMappingURL=types.d.ts.map |
@@ -1,2 +0,2 @@ | ||
| export declare const VERSION = "2.0.1"; | ||
| export declare const VERSION = "2.1.0"; | ||
| //# sourceMappingURL=version.d.ts.map |
@@ -20,3 +20,3 @@ "use strict"; | ||
| // this is autogenerated file, see scripts/version-update.js | ||
| exports.VERSION = '2.0.1'; | ||
| exports.VERSION = '2.1.0'; | ||
| //# sourceMappingURL=version.js.map |
+7
-8
| { | ||
| "name": "@opentelemetry/resources", | ||
| "version": "2.0.1", | ||
| "version": "2.1.0", | ||
| "description": "OpenTelemetry SDK resources", | ||
@@ -31,3 +31,3 @@ "main": "build/src/index.js", | ||
| "version": "node ../../scripts/version-update.js", | ||
| "precompile": "cross-var lerna run version --scope $npm_package_name --include-dependencies", | ||
| "precompile": "lerna run version --scope @opentelemetry/resources --include-dependencies", | ||
| "prewatch": "npm run precompile", | ||
@@ -72,3 +72,2 @@ "peer-api-check": "node ../../scripts/peer-api-check.js", | ||
| "@types/webpack-env": "1.16.3", | ||
| "cross-var": "1.1.0", | ||
| "karma": "6.4.4", | ||
@@ -82,8 +81,8 @@ "karma-chrome-launcher": "3.1.0", | ||
| "lerna": "6.6.2", | ||
| "mocha": "11.1.0", | ||
| "mocha": "11.7.2", | ||
| "nock": "13.5.6", | ||
| "nyc": "17.1.0", | ||
| "sinon": "15.1.2", | ||
| "sinon": "18.0.1", | ||
| "typescript": "5.0.4", | ||
| "webpack": "5.99.8", | ||
| "webpack": "5.101.3", | ||
| "webpack-cli": "6.0.1" | ||
@@ -95,3 +94,3 @@ }, | ||
| "dependencies": { | ||
| "@opentelemetry/core": "2.0.1", | ||
| "@opentelemetry/core": "2.1.0", | ||
| "@opentelemetry/semantic-conventions": "^1.29.0" | ||
@@ -101,3 +100,3 @@ }, | ||
| "sideEffects": false, | ||
| "gitHead": "4ce5bd165195870f292fa95e312cffe05eb9e09d" | ||
| "gitHead": "98f9d720af84bc38074dfd4ab7760ae83a3e9826" | ||
| } |
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
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
561055
2.53%20
-4.76%6151
1.99%+ Added
- Removed
Updated