Skip to content

Commit

Permalink
Add driver type information in service-client telemetry (microsoft#22964
Browse files Browse the repository at this point in the history
)

This change adds `driver`, `driverEndpointName` and `testVariant`
information to service-client telemetry. Rest of the field such as
`clientType`, `loaderId` and `containerId` are not displayed as part of
`Test_start` and `Test_end` event name

[Execute](
https://dataexplorer.azure.com/clusters/kusto.aria.microsoft.com/databases/742fa5a288b045e5beab1a2b8e445a71?query=H4sIAAAAAAAAA1WPsU7DQAyG9z6FdRMgUItg4AHokIUpYj25dz5yKLEjn9OqEg%2FPoSal2Wz%2F3%2B%2FfnjgLg6SUA%2FnUTzn6lHAyGdCq4h82P3DqSAne0dAfptzHJkJmuHMvu7fX5527XyNGxT5wIOiwgAvILAZohqEDhCBsmJkU7FQj3Wa7hZWdjsQ3%2FrZu83uOroaIxuo7nGH%2FxzScxLe5glhCVUeVbwr2pHTh1tDj%2F3GfqBnZ5knUfCRtzyOtBjVylHy5ZBZCn%2BvGG7IXrEFNXPTltevk%2BsvcD1QKfi0dqYrOtRIW4V%2BVtJA1jQEAAA%3D%3D)

union office_fluid_ffautomation_*
| where Data_buildId in ("308410")
| where Data_testName has "cannot attach a container twice"
// | where Data_eventName has "Test_End"
| order by EventInfo_Time asc
| project-reorder EventInfo_Time, Data_testVariant, Data_driverType,
Data_driverEndpointName, Data_clientType, Data_loaderId,
Data_containerId, Data_eventName, Data_message, Data_error, Data_reason

The `Test_End` event lacks `Data_driverType` and
`Data_driverEndpointName` field, which are present in other events.

Test run:
https://dev.azure.com/fluidframework/internal/_build/results?buildId=308410&view=results

[ADO Work
Item](https://dev.azure.com/fluidframework/internal/_workitems/edit/8762)
  • Loading branch information
sonalideshpandemsft authored Nov 22, 2024
1 parent 9a3fa55 commit f1c1c31
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,12 @@
"test": "npm run test:realsvc",
"test:coverage": "c8 npm test",
"test:realsvc": "npm run test:realsvc:tinylicious",
"test:realsvc:azure": "cross-env FLUID_CLIENT=azure npm run test:realsvc:azure:run",
"test:realsvc:azure": "cross-env FLUID_CLIENT=azure npm run test:realsvc:azure:run -- --driver=r11s --r11sEndpointName=frs",
"test:realsvc:azure:run": "mocha --recursive \"lib/test/**/*.spec.*js\" --exit --timeout 20000 --config src/test/.mocharc.cjs",
"test:realsvc:run": "mocha lib/test --config src/test/.mocharc.cjs",
"test:realsvc:tinylicious": "start-server-and-test start:tinylicious:test 7071 test:realsvc:azure:run",
"test:realsvc:tinylicious": "start-server-and-test start:tinylicious:test 7071 test:realsvc:tinylicious:run",
"test:realsvc:tinylicious:report": "npm run test:realsvc:tinylicious",
"test:realsvc:tinylicious:run": "npm run test:realsvc:azure:run -- --driver=t9s",
"test:realsvc:verbose": "cross-env FLUID_TEST_VERBOSE=1 npm run test:realsvc"
},
"c8": {
Expand All @@ -62,6 +63,7 @@
"@fluid-experimental/data-objects": "workspace:~",
"@fluid-internal/client-utils": "workspace:~",
"@fluid-internal/mocha-test-setup": "workspace:~",
"@fluid-private/test-version-utils": "workspace:~",
"@fluidframework/aqueduct": "workspace:~",
"@fluidframework/azure-client": "workspace:~",
"@fluidframework/azure-client-legacy": "npm:@fluidframework/azure-client@^1.2.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"use strict";

const packageDir = `${__dirname}/../..`;
const getFluidTestMochaConfig = require("@fluid-internal/mocha-test-setup/mocharc-common");
const getFluidTestMochaConfig = require("@fluid-private/test-version-utils/mocharc-common");
const config = getFluidTestMochaConfig(packageDir);

module.exports = config;
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ import {
ITelemetryBaseLogger as ITelemetryBaseLoggerLegacy,
} from "@fluidframework/azure-client-legacy";
import { IConfigProviderBase } from "@fluidframework/core-interfaces";
import { MockLogger, createMultiSinkLogger } from "@fluidframework/telemetry-utils/internal";
import {
MockLogger,
createChildLogger,
createMultiSinkLogger,
} from "@fluidframework/telemetry-utils/internal";
import { InsecureTokenProvider } from "@fluidframework/test-runtime-utils/internal";
import { default as Axios, AxiosResponse, type AxiosRequestConfig } from "axios";
import { v4 as uuid } from "uuid";
Expand All @@ -35,6 +39,16 @@ export function createAzureClient(
configProvider?: IConfigProviderBase,
scopes?: ScopeType[],
): AzureClient {
const args = process.argv.slice(2);

const driverIndex = args.indexOf("--driver");
const r11sEndpointNameIndex = args.indexOf("--r11sEndpointName");

// Get values associated with the flags
const driver = driverIndex === -1 ? undefined : args[driverIndex + 1];
const r11sEndpointName =
r11sEndpointNameIndex === -1 ? undefined : args[r11sEndpointNameIndex + 1];

const useAzure = process.env.FLUID_CLIENT === "azure";
const tenantId = useAzure
? (process.env.azure__fluid__relay__service__tenantId as string)
Expand Down Expand Up @@ -73,9 +87,19 @@ export function createAzureClient(
}
return logger ?? testLogger;
};

const createLogger = createChildLogger({
logger: getLogger(),
properties: {
all: {
driverType: useAzure ? r11sEndpointName : driver,
driverEndpointName: driver,
},
},
});
return new AzureClient({
connection: connectionProps,
logger: getLogger(),
logger: createLogger,
configProvider,
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
"lint:fix": "fluid-build . --task eslint:fix --task format",
"test": "npm run test:realsvc:odsp:run",
"test:coverage": "c8 npm test",
"test:realsvc:odsp": "cross-env npm run test:realsvc:odsp:run",
"test:realsvc:odsp:run": "mocha --recursive \"lib/test/**/*.spec.*js\" --exit --timeout 20000",
"test:realsvc:odsp": "cross-env npm run test:realsvc:odsp:run -- --driver=odsp --odspEndpointName=odsp",
"test:realsvc:odsp:run": "mocha --recursive \"lib/test/**/*.spec.*js\" --exit --timeout 20000 --config src/test/.mocharc.cjs",
"test:realsvc:run": "mocha --recursive \"lib/test/**/*.spec.*js\"",
"test:realsvc:verbose": "cross-env FLUID_TEST_VERBOSE=1 npm run test:realsvc"
},
Expand All @@ -56,6 +56,7 @@
},
"dependencies": {
"@fluid-internal/mocha-test-setup": "workspace:~",
"@fluid-private/test-version-utils": "workspace:~",
"@fluidframework/aqueduct": "workspace:~",
"@fluidframework/container-definitions": "workspace:~",
"@fluidframework/container-loader": "workspace:~",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

"use strict";

const getFluidTestMochaConfig = require("@fluid-internal/mocha-test-setup/mocharc-common");

const packageDir = __dirname;
const packageDir = `${__dirname}/../..`;
const getFluidTestMochaConfig = require("@fluid-private/test-version-utils/mocharc-common");
const config = getFluidTestMochaConfig(packageDir);

module.exports = config;
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ import {
type ITelemetryBaseLogger,
} from "@fluidframework/core-interfaces";
import { OdspClient, OdspConnectionConfig } from "@fluidframework/odsp-client/internal";
import { MockLogger, createMultiSinkLogger } from "@fluidframework/telemetry-utils/internal";
import {
MockLogger,
createChildLogger,
createMultiSinkLogger,
} from "@fluidframework/telemetry-utils/internal";

import { OdspTestTokenProvider } from "./OdspTokenFactory.js";

Expand Down Expand Up @@ -128,6 +132,16 @@ export function createOdspClient(
throw new Error("client id is missing");
}

const args = process.argv.slice(2);

const driverIndex = args.indexOf("--driver");
const odspEndpointNameIndex = args.indexOf("--odspEndpointName");

// Get values associated with the flags
const driverType = driverIndex === -1 ? undefined : args[driverIndex + 1];
const driverEndpointName =
odspEndpointNameIndex === -1 ? undefined : args[odspEndpointNameIndex + 1];

const credentials: IOdspCredentials = {
clientId,
...creds,
Expand All @@ -139,6 +153,7 @@ export function createOdspClient(
driveId,
filePath: "",
};

const getLogger = (): ITelemetryBaseLogger | undefined => {
const testLogger = getTestLogger?.();
if (!logger && !testLogger) {
Expand All @@ -149,9 +164,20 @@ export function createOdspClient(
}
return logger ?? testLogger;
};

const createLogger = createChildLogger({
logger: getLogger(),
properties: {
all: {
driverType,
driverEndpointName,
},
},
});

return new OdspClient({
connection: connectionProps,
logger: getLogger(),
logger: createLogger,
configProvider,
});
}
6 changes: 6 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit f1c1c31

Please sign in to comment.