@opentelemetry/resource-detector-azure 0.2.0 → 0.2.2

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.
@@ -33,8 +33,8 @@ class AzureFunctionsDetector {
33
33
  detect() {
34
34
  let attributes = {};
35
35
  const functionName = process.env[types_1.WEBSITE_SITE_NAME];
36
- if (functionName) {
37
- const functionVersion = process.env[types_1.FUNCTIONS_VERSION];
36
+ const functionVersion = process.env[types_1.FUNCTIONS_VERSION];
37
+ if (functionName && functionVersion) {
38
38
  const functionInstance = process.env[types_1.WEBSITE_INSTANCE_ID];
39
39
  const functionMemLimit = process.env[types_1.FUNCTIONS_MEM_LIMIT];
40
40
  attributes = {
@@ -1 +1 @@
1
- {"version":3,"file":"AzureFunctionsDetector.js","sourceRoot":"","sources":["../../../src/detectors/AzureFunctionsDetector.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,wDAA6E;AAE7E,8EAI6C;AAC7C,oCAMkB;AAElB,MAAM,kCAAkC,GAAG;IACzC,CAAC,iDAA0B,CAAC,SAAS,CAAC,EAAE,yBAAiB;IACzD,CAAC,iDAA0B,CAAC,YAAY,CAAC,EAAE,yBAAiB;IAC5D,CAAC,iDAA0B,CAAC,aAAa,CAAC,EAAE,2BAAmB;IAC/D,CAAC,iDAA0B,CAAC,eAAe,CAAC,EAAE,2BAAmB;CAClE,CAAC;AAEF;;;GAGG;AACH,MAAM,sBAAsB;IAC1B,MAAM;QACJ,IAAI,UAAU,GAAG,EAAE,CAAC;QACpB,MAAM,YAAY,GAAG,OAAO,CAAC,GAAG,CAAC,yBAAiB,CAAC,CAAC;QACpD,IAAI,YAAY,EAAE;YAChB,MAAM,eAAe,GAAG,OAAO,CAAC,GAAG,CAAC,yBAAiB,CAAC,CAAC;YACvD,MAAM,gBAAgB,GAAG,OAAO,CAAC,GAAG,CAAC,2BAAmB,CAAC,CAAC;YAC1D,MAAM,gBAAgB,GAAG,OAAO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(the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { DetectorSync, IResource, Resource } from '@opentelemetry/resources';\n\nimport {\n CloudProviderValues,\n CloudPlatformValues,\n SemanticResourceAttributes,\n} from '@opentelemetry/semantic-conventions';\nimport {\n WEBSITE_SITE_NAME,\n FUNCTIONS_VERSION,\n WEBSITE_INSTANCE_ID,\n FUNCTIONS_MEM_LIMIT,\n REGION_NAME,\n} from '../types';\n\nconst AZURE_FUNCTIONS_ATTRIBUTE_ENV_VARS = {\n [SemanticResourceAttributes.FAAS_NAME]: WEBSITE_SITE_NAME,\n [SemanticResourceAttributes.FAAS_VERSION]: FUNCTIONS_VERSION,\n [SemanticResourceAttributes.FAAS_INSTANCE]: WEBSITE_INSTANCE_ID,\n [SemanticResourceAttributes.FAAS_MAX_MEMORY]: FUNCTIONS_MEM_LIMIT,\n};\n\n/**\n * The AzureFunctionsDetector can be used to detect if a process is running in Azure Functions\n * @returns a {@link Resource} populated with data about the environment or an empty Resource if detection fails.\n */\nclass AzureFunctionsDetector implements DetectorSync {\n detect(): IResource {\n let attributes = {};\n const functionName = process.env[WEBSITE_SITE_NAME];\n if (functionName) {\n const functionVersion = process.env[FUNCTIONS_VERSION];\n const functionInstance = process.env[WEBSITE_INSTANCE_ID];\n const functionMemLimit = process.env[FUNCTIONS_MEM_LIMIT];\n\n attributes = {\n [SemanticResourceAttributes.CLOUD_PROVIDER]: CloudProviderValues.AZURE,\n [SemanticResourceAttributes.CLOUD_PLATFORM]:\n CloudPlatformValues.AZURE_FUNCTIONS,\n [SemanticResourceAttributes.CLOUD_REGION]: process.env[REGION_NAME],\n };\n\n if (functionName) {\n attributes = {\n ...attributes,\n [SemanticResourceAttributes.FAAS_NAME]: functionName,\n };\n }\n if (functionVersion) {\n attributes = {\n ...attributes,\n [SemanticResourceAttributes.FAAS_VERSION]: functionVersion,\n };\n }\n if (functionInstance) {\n attributes = {\n ...attributes,\n [SemanticResourceAttributes.FAAS_INSTANCE]: functionInstance,\n };\n }\n if (functionMemLimit) {\n attributes = {\n ...attributes,\n [SemanticResourceAttributes.FAAS_MAX_MEMORY]: functionMemLimit,\n };\n }\n\n for (const [key, value] of Object.entries(\n AZURE_FUNCTIONS_ATTRIBUTE_ENV_VARS\n )) {\n const envVar = process.env[value];\n if (envVar) {\n attributes = { ...attributes, ...{ [key]: envVar } };\n }\n }\n }\n return new Resource(attributes);\n }\n}\n\nexport const azureFunctionsDetector = new AzureFunctionsDetector();\n"]}
1
+ {"version":3,"file":"AzureFunctionsDetector.js","sourceRoot":"","sources":["../../../src/detectors/AzureFunctionsDetector.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,wDAA6E;AAE7E,8EAI6C;AAC7C,oCAMkB;AAElB,MAAM,kCAAkC,GAAG;IACzC,CAAC,iDAA0B,CAAC,SAAS,CAAC,EAAE,yBAAiB;IACzD,CAAC,iDAA0B,CAAC,YAAY,CAAC,EAAE,yBAAiB;IAC5D,CAAC,iDAA0B,CAAC,aAAa,CAAC,EAAE,2BAAmB;IAC/D,CAAC,iDAA0B,CAAC,eAAe,CAAC,EAAE,2BAAmB;CAClE,CAAC;AAEF;;;GAGG;AACH,MAAM,sBAAsB;IAC1B,MAAM;QACJ,IAAI,UAAU,GAAG,EAAE,CAAC;QACpB,MAAM,YAAY,GAAG,OAAO,CAAC,GAAG,CAAC,yBAAiB,CAAC,CAAC;QACpD,MAAM,eAAe,GAAG,OAAO,CAAC,GAAG,CAAC,yBAAiB,CAAC,CAAC;QACvD,IAAI,YAAY,IAAI,eAAe,EAAE;YACnC,MAAM,gBAAgB,GAAG,OAAO,CAAC,GAAG,CAAC,2BAAmB,CAAC,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Telemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { DetectorSync, IResource, Resource } from '@opentelemetry/resources';\n\nimport {\n CloudProviderValues,\n CloudPlatformValues,\n SemanticResourceAttributes,\n} from '@opentelemetry/semantic-conventions';\nimport {\n WEBSITE_SITE_NAME,\n FUNCTIONS_VERSION,\n WEBSITE_INSTANCE_ID,\n FUNCTIONS_MEM_LIMIT,\n REGION_NAME,\n} from '../types';\n\nconst AZURE_FUNCTIONS_ATTRIBUTE_ENV_VARS = {\n [SemanticResourceAttributes.FAAS_NAME]: WEBSITE_SITE_NAME,\n [SemanticResourceAttributes.FAAS_VERSION]: FUNCTIONS_VERSION,\n [SemanticResourceAttributes.FAAS_INSTANCE]: WEBSITE_INSTANCE_ID,\n [SemanticResourceAttributes.FAAS_MAX_MEMORY]: FUNCTIONS_MEM_LIMIT,\n};\n\n/**\n * The AzureFunctionsDetector can be used to detect if a process is running in Azure Functions\n * @returns a {@link Resource} populated with data about the environment or an empty Resource if detection fails.\n */\nclass AzureFunctionsDetector implements DetectorSync {\n detect(): IResource {\n let attributes = {};\n const functionName = process.env[WEBSITE_SITE_NAME];\n const functionVersion = process.env[FUNCTIONS_VERSION];\n if (functionName && functionVersion) {\n const functionInstance = process.env[WEBSITE_INSTANCE_ID];\n const functionMemLimit = process.env[FUNCTIONS_MEM_LIMIT];\n\n attributes = {\n [SemanticResourceAttributes.CLOUD_PROVIDER]: CloudProviderValues.AZURE,\n [SemanticResourceAttributes.CLOUD_PLATFORM]:\n CloudPlatformValues.AZURE_FUNCTIONS,\n [SemanticResourceAttributes.CLOUD_REGION]: process.env[REGION_NAME],\n };\n\n if (functionName) {\n attributes = {\n ...attributes,\n [SemanticResourceAttributes.FAAS_NAME]: functionName,\n };\n }\n if (functionVersion) {\n attributes = {\n ...attributes,\n [SemanticResourceAttributes.FAAS_VERSION]: functionVersion,\n };\n }\n if (functionInstance) {\n attributes = {\n ...attributes,\n [SemanticResourceAttributes.FAAS_INSTANCE]: functionInstance,\n };\n }\n if (functionMemLimit) {\n attributes = {\n ...attributes,\n [SemanticResourceAttributes.FAAS_MAX_MEMORY]: functionMemLimit,\n };\n }\n\n for (const [key, value] of Object.entries(\n AZURE_FUNCTIONS_ATTRIBUTE_ENV_VARS\n )) {\n const envVar = process.env[value];\n if (envVar) {\n attributes = { ...attributes, ...{ [key]: envVar } };\n }\n }\n }\n return new Resource(attributes);\n }\n}\n\nexport const azureFunctionsDetector = new AzureFunctionsDetector();\n"]}
@@ -1,2 +1,4 @@
1
1
  export * from './AzureAppServiceDetector';
2
+ export * from './AzureFunctionsDetector';
3
+ export * from './AzureVmDetector';
2
4
  //# sourceMappingURL=index.d.ts.map
@@ -26,4 +26,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
26
26
  };
27
27
  Object.defineProperty(exports, "__esModule", { value: true });
28
28
  __exportStar(require("./AzureAppServiceDetector"), exports);
29
+ __exportStar(require("./AzureFunctionsDetector"), exports);
30
+ __exportStar(require("./AzureVmDetector"), exports);
29
31
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/detectors/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;;;;;;;;;;AAEH,4DAA0C","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport * from './AzureAppServiceDetector';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/detectors/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;;;;;;;;;;AAEH,4DAA0C;AAC1C,2DAAyC;AACzC,oDAAkC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport * from './AzureAppServiceDetector';\nexport * from './AzureFunctionsDetector';\nexport * from './AzureVmDetector';\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opentelemetry/resource-detector-azure",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "description": "OpenTelemetry SDK resource detector for Azure",
5
5
  "main": "build/src/index.js",
6
6
  "types": "build/src/index.d.ts",
@@ -12,7 +12,7 @@
12
12
  "lint:fix": "eslint . --ext .ts --fix",
13
13
  "precompile": "tsc --version && lerna run version:update --scope @opentelemetry/resource-detector-azure --include-dependencies",
14
14
  "prewatch": "npm run precompile",
15
- "prepare": "npm run compile",
15
+ "prepublishOnly": "npm run compile",
16
16
  "test": "nyc ts-mocha -p tsconfig.json 'test/**/*.test.ts'",
17
17
  "tdd": "npm run test -- --watch-extensions ts --watch",
18
18
  "watch": "tsc -w"
@@ -32,7 +32,7 @@
32
32
  },
33
33
  "devDependencies": {
34
34
  "@opentelemetry/api": "^1.0.0",
35
- "@opentelemetry/contrib-test-utils": "^0.34.3",
35
+ "@opentelemetry/contrib-test-utils": "^0.35.0",
36
36
  "@types/mocha": "8.2.3",
37
37
  "@types/node": "18.6.5",
38
38
  "@types/sinon": "10.0.18",
@@ -48,5 +48,5 @@
48
48
  "@opentelemetry/semantic-conventions": "^1.0.0"
49
49
  },
50
50
  "homepage": "https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/detectors/node/opentelemetry-resource-detector-azure#readme",
51
- "gitHead": "607d375595da3ab51b7f773ac360900121c4361b"
51
+ "gitHead": "c7e7000b7bf79b0b107c448b403c2613a9b9e2c1"
52
52
  }