Skip to content

Commit

Permalink
Merge branch 'main' into ej/azfunc
Browse files Browse the repository at this point in the history
  • Loading branch information
ejizba committed Jun 10, 2024
2 parents c4e0a0c + dadf308 commit d5d2604
Show file tree
Hide file tree
Showing 31 changed files with 679 additions and 704 deletions.
12 changes: 6 additions & 6 deletions .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"detectors/node/opentelemetry-resource-detector-alibaba-cloud": "0.28.10",
"detectors/node/opentelemetry-resource-detector-aws": "1.5.1",
"detectors/node/opentelemetry-resource-detector-azure": "0.2.8",
"detectors/node/opentelemetry-resource-detector-container": "0.3.10",
"detectors/node/opentelemetry-resource-detector-azure": "0.2.9",
"detectors/node/opentelemetry-resource-detector-container": "0.3.11",
"detectors/node/opentelemetry-resource-detector-gcp": "0.29.10",
"detectors/node/opentelemetry-resource-detector-github": "0.28.2",
"detectors/node/opentelemetry-resource-detector-instana": "0.10.0",
"metapackages/auto-instrumentations-node": "0.47.0",
"metapackages/auto-instrumentations-node": "0.47.1",
"metapackages/auto-instrumentations-web": "0.40.0",
"packages/baggage-span-processor": "0.3.0",
"packages/baggage-span-processor": "0.3.1",
"packages/opentelemetry-host-metrics": "0.35.2",
"packages/opentelemetry-id-generator-aws-xray": "1.2.2",
"packages/opentelemetry-propagation-utils": "0.30.10",
Expand All @@ -34,7 +34,7 @@
"plugins/node/opentelemetry-instrumentation-cassandra": "0.39.0",
"plugins/node/opentelemetry-instrumentation-connect": "0.37.0",
"plugins/node/opentelemetry-instrumentation-dns": "0.37.0",
"plugins/node/opentelemetry-instrumentation-express": "0.40.0",
"plugins/node/opentelemetry-instrumentation-express": "0.40.1",
"plugins/node/opentelemetry-instrumentation-fastify": "0.37.0",
"plugins/node/opentelemetry-instrumentation-generic-pool": "0.37.0",
"plugins/node/opentelemetry-instrumentation-graphql": "0.41.0",
Expand All @@ -43,7 +43,7 @@
"plugins/node/opentelemetry-instrumentation-knex": "0.37.0",
"plugins/node/opentelemetry-instrumentation-koa": "0.41.0",
"plugins/node/opentelemetry-instrumentation-memcached": "0.37.0",
"plugins/node/opentelemetry-instrumentation-mongodb": "0.44.0",
"plugins/node/opentelemetry-instrumentation-mongodb": "0.45.0",
"plugins/node/opentelemetry-instrumentation-mysql": "0.39.0",
"plugins/node/opentelemetry-instrumentation-mysql2": "0.39.0",
"plugins/node/opentelemetry-instrumentation-nestjs-core": "0.38.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## [0.2.9](https://github.com/open-telemetry/opentelemetry-js-contrib/compare/resource-detector-azure-v0.2.8...resource-detector-azure-v0.2.9) (2024-06-10)


### Bug Fixes

* **azure-functions-resource-detector:** Update Azure Functions Detector to Consider WEBSITE_SKU ([#2251](https://github.com/open-telemetry/opentelemetry-js-contrib/issues/2251)) ([93776fa](https://github.com/open-telemetry/opentelemetry-js-contrib/commit/93776fad10fb46ba4ba2bfe31a4825ec0929fd50))

## [0.2.8](https://github.com/open-telemetry/opentelemetry-js-contrib/compare/resource-detector-azure-v0.2.7...resource-detector-azure-v0.2.8) (2024-06-06)


Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@opentelemetry/resource-detector-azure",
"version": "0.2.8",
"version": "0.2.9",
"description": "OpenTelemetry SDK resource detector for Azure",
"main": "build/src/index.js",
"types": "build/src/index.d.ts",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import {
WEBSITE_SITE_NAME,
WEBSITE_SLOT_NAME,
CLOUD_RESOURCE_ID_RESOURCE_ATTRIBUTE,
FUNCTIONS_VERSION,
} from '../types';
import {
SEMRESATTRS_CLOUD_REGION,
Expand All @@ -37,7 +36,7 @@ import {
CLOUDPROVIDERVALUES_AZURE,
CLOUDPLATFORMVALUES_AZURE_APP_SERVICE,
} from '@opentelemetry/semantic-conventions';
import { getAzureResourceUri } from '../utils';
import { getAzureResourceUri, isAzureFunction } from '../utils';

const APP_SERVICE_ATTRIBUTE_ENV_VARS = {
[SEMRESATTRS_CLOUD_REGION]: REGION_NAME,
Expand All @@ -55,8 +54,7 @@ class AzureAppServiceDetector implements DetectorSync {
detect(): IResource {
let attributes = {};
const websiteSiteName = process.env[WEBSITE_SITE_NAME];
const isAzureFunction = !!process.env[FUNCTIONS_VERSION];
if (websiteSiteName && !isAzureFunction) {
if (websiteSiteName && !isAzureFunction()) {
attributes = {
...attributes,
[SEMRESATTRS_SERVICE_NAME]: websiteSiteName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,12 @@ import {
} from '@opentelemetry/semantic-conventions';
import {
WEBSITE_SITE_NAME,
FUNCTIONS_VERSION,
WEBSITE_INSTANCE_ID,
FUNCTIONS_MEM_LIMIT,
REGION_NAME,
CLOUD_RESOURCE_ID_RESOURCE_ATTRIBUTE,
} from '../types';
import { getAzureResourceUri } from '../utils';
import { getAzureResourceUri, isAzureFunction } from '../utils';

const AZURE_FUNCTIONS_ATTRIBUTE_ENV_VARS = {
[SEMRESATTRS_SERVICE_NAME]: WEBSITE_SITE_NAME,
Expand All @@ -51,13 +50,13 @@ class AzureFunctionsDetector implements DetectorSync {
detect(): IResource {
let attributes = {};
const serviceName = process.env[WEBSITE_SITE_NAME];
const functionVersion = process.env[FUNCTIONS_VERSION];

/**
* Checks that we are operating within an Azure Function using the function version since WEBSITE_SITE_NAME
* will exist in Azure App Service as well and detectors should be mutually exclusive.
* If the function version is not present, we check for the website sku to determine if it is a function.
*/
if (serviceName && functionVersion) {
if (serviceName && isAzureFunction()) {
const functionInstance = process.env[WEBSITE_INSTANCE_ID];
const functionMemLimit = process.env[FUNCTIONS_MEM_LIMIT];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export const WEBSITE_OWNER_NAME = 'WEBSITE_OWNER_NAME';
export const WEBSITE_RESOURCE_GROUP = 'WEBSITE_RESOURCE_GROUP';
export const WEBSITE_SITE_NAME = 'WEBSITE_SITE_NAME';
export const WEBSITE_SLOT_NAME = 'WEBSITE_SLOT_NAME';
export const WEBSITE_SKU = 'WEBSITE_SKU';

export const FUNCTIONS_VERSION = 'FUNCTIONS_EXTENSION_VERSION';
export const FUNCTIONS_MEM_LIMIT = 'WEBSITE_MEMORY_LIMIT_MB';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@
* limitations under the License.
*/

import { WEBSITE_OWNER_NAME, WEBSITE_RESOURCE_GROUP } from './types';
import {
FUNCTIONS_VERSION,
WEBSITE_OWNER_NAME,
WEBSITE_RESOURCE_GROUP,
WEBSITE_SKU,
} from './types';

export function getAzureResourceUri(
websiteSiteName: string
Expand All @@ -33,3 +38,10 @@ export function getAzureResourceUri(

return `/subscriptions/${subscriptionId}/resourceGroups/${websiteResourceGroup}/providers/Microsoft.Web/sites/${websiteSiteName}`;
}

export function isAzureFunction(): boolean {
return !!(
process.env[FUNCTIONS_VERSION] ||
process.env[WEBSITE_SKU] === 'FlexConsumption'
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,27 @@ describe('AzureFunctionsDetector', () => {
);
});
});

it('should detect azure functions if websiteSku is defined as FlexConsumption', () => {
assert.ok(!process.env.WEBSITE_SKU && !process.env.FUNCTIONS_VERSION);
process.env.WEBSITE_SITE_NAME = 'test-service';
process.env.REGION_NAME = 'test-region';
process.env.WEBSITE_INSTANCE_ID = 'test-instance-id';
process.env.WEBSITE_SKU = 'FlexConsumption';
process.env.WEBSITE_MEMORY_LIMIT_MB = '1000';
process.env.WEBSITE_OWNER_NAME = 'test-owner-name';
process.env.WEBSITE_RESOURCE_GROUP = 'test-resource-group';

const resource = detectResourcesSync({
detectors: [azureFunctionsDetector, azureAppServiceDetector],
});
assert.ok(resource);
const attributes = resource.attributes;
assert.strictEqual(attributes[SEMRESATTRS_SERVICE_NAME], 'test-service');
assert.strictEqual(attributes[SEMRESATTRS_CLOUD_PROVIDER], 'azure');

// Should not detect app service values
assert.strictEqual(attributes[SEMRESATTRS_SERVICE_INSTANCE_ID], undefined);
assert.strictEqual(attributes[SEMRESATTRS_PROCESS_PID], process.pid);
delete process.env.WEBSITE_SKU;
});
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## [0.3.11](https://github.com/open-telemetry/opentelemetry-js-contrib/compare/resource-detector-container-v0.3.10...resource-detector-container-v0.3.11) (2024-06-10)


### Bug Fixes

* ContainerId not detected post version 0.2.2 ([#2270](https://github.com/open-telemetry/opentelemetry-js-contrib/issues/2270)) ([9761a91](https://github.com/open-telemetry/opentelemetry-js-contrib/commit/9761a9160c862b9f8a35c00afc26217973e4462a))

## [0.3.10](https://github.com/open-telemetry/opentelemetry-js-contrib/compare/resource-detector-container-v0.3.9...resource-detector-container-v0.3.10) (2024-06-06)


Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@opentelemetry/resource-detector-container",
"version": "0.3.10",
"version": "0.3.11",
"description": "Opentelemetry resource detector to get container resource attributes",
"main": "build/src/index.js",
"types": "build/src/index.d.ts",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export class ContainerDetector implements Detector {
private async _getContainerId(): Promise<string | undefined> {
try {
return (
(await this._getContainerIdV1()) ?? (await this._getContainerIdV2())
(await this._getContainerIdV1()) || (await this._getContainerIdV2())
);
} catch (e) {
if (e instanceof Error) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,16 @@ describe('ContainerDetector', () => {
assert.ok(resource);
});

it('should return a correctCgroupV2Data resource with v1Detector returns empty string ', async () => {
readStub = sinon.stub(ContainerDetector, 'readFileAsync' as any);
sinon.stub(containerDetector, '_getContainerIdV1' as any).resolves('');
sinon
.stub(containerDetector, '_getContainerIdV2' as any)
.resolves(correctCgroupV2Data);
const containerId = await containerDetector['_getContainerId']();
assert.strictEqual(containerId, correctCgroupV2Data);
});

it('should return a resource without attribute container.id when cgroup file does not contain valid Container ID', async () => {
readStub = sinon
.stub(ContainerDetector, 'readFileAsync' as any)
Expand Down
12 changes: 12 additions & 0 deletions metapackages/auto-instrumentations-node/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# Changelog

## [0.47.1](https://github.com/open-telemetry/opentelemetry-js-contrib/compare/auto-instrumentations-node-v0.47.0...auto-instrumentations-node-v0.47.1) (2024-06-10)


### Dependencies

* The following workspace dependencies were updated
* dependencies
* @opentelemetry/instrumentation-express bumped from ^0.40.0 to ^0.40.1
* @opentelemetry/instrumentation-mongodb bumped from ^0.44.0 to ^0.45.0
* @opentelemetry/resource-detector-azure bumped from ^0.2.8 to ^0.2.9
* @opentelemetry/resource-detector-container bumped from ^0.3.10 to ^0.3.11

## [0.47.0](https://github.com/open-telemetry/opentelemetry-js-contrib/compare/auto-instrumentations-node-v0.46.1...auto-instrumentations-node-v0.47.0) (2024-06-06)


Expand Down
10 changes: 5 additions & 5 deletions metapackages/auto-instrumentations-node/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@opentelemetry/auto-instrumentations-node",
"version": "0.47.0",
"version": "0.47.1",
"description": "Metapackage which bundles opentelemetry node core and contrib instrumentations",
"author": "OpenTelemetry Authors",
"homepage": "https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/metapackages/auto-instrumentations-node#readme",
Expand Down Expand Up @@ -59,7 +59,7 @@
"@opentelemetry/instrumentation-cucumber": "^0.7.0",
"@opentelemetry/instrumentation-dataloader": "^0.10.0",
"@opentelemetry/instrumentation-dns": "^0.37.0",
"@opentelemetry/instrumentation-express": "^0.40.0",
"@opentelemetry/instrumentation-express": "^0.40.1",
"@opentelemetry/instrumentation-fastify": "^0.37.0",
"@opentelemetry/instrumentation-fs": "^0.13.0",
"@opentelemetry/instrumentation-generic-pool": "^0.37.0",
Expand All @@ -72,7 +72,7 @@
"@opentelemetry/instrumentation-koa": "^0.41.0",
"@opentelemetry/instrumentation-lru-memoizer": "^0.38.0",
"@opentelemetry/instrumentation-memcached": "^0.37.0",
"@opentelemetry/instrumentation-mongodb": "^0.44.0",
"@opentelemetry/instrumentation-mongodb": "^0.45.0",
"@opentelemetry/instrumentation-mongoose": "^0.39.0",
"@opentelemetry/instrumentation-mysql": "^0.39.0",
"@opentelemetry/instrumentation-mysql2": "^0.39.0",
Expand All @@ -90,8 +90,8 @@
"@opentelemetry/instrumentation-winston": "^0.38.0",
"@opentelemetry/resource-detector-alibaba-cloud": "^0.28.10",
"@opentelemetry/resource-detector-aws": "^1.5.1",
"@opentelemetry/resource-detector-azure": "^0.2.8",
"@opentelemetry/resource-detector-container": "^0.3.10",
"@opentelemetry/resource-detector-azure": "^0.2.9",
"@opentelemetry/resource-detector-container": "^0.3.11",
"@opentelemetry/resource-detector-gcp": "^0.29.10",
"@opentelemetry/resources": "^1.24.0",
"@opentelemetry/sdk-node": "^0.52.0"
Expand Down
Loading

0 comments on commit d5d2604

Please sign in to comment.