Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automation: main-next integrate #16498

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .changeset/short-apples-wear.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
"@fluidframework/telemetry-utils": minor
---

Deprecate Internal TelemetryLogger Implementations

This change deprecates our internal TelemetryLogger implementations and unifies our exported and consumed surface area on our telemetry interfaces.

For the deprecated implementations the following replacement function should be used:

- replace ChildLogger.create, new TelemetryNullLogger, and new BaseTelemetryNullLogger with createChildLogger
- replace DebugLogger.create with createDebugLogger
- replace new MultiSinkLogger with createMultiSinkLogger
- replace TelemetryUTLogger with MockLogger
4 changes: 2 additions & 2 deletions api-report/local-driver.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ export class LocalDeltaStorageService implements IDocumentDeltaStorageService {

// @public
export class LocalDocumentDeltaConnection extends DocumentDeltaConnection {
constructor(socket: Socket, documentId: string);
static create(tenantId: string, id: string, token: string, client: IClient, webSocketServer: IWebSocketServer, timeoutMs?: number): Promise<LocalDocumentDeltaConnection>;
constructor(socket: Socket, documentId: string, logger?: ITelemetryBaseLogger);
static create(tenantId: string, id: string, token: string, client: IClient, webSocketServer: IWebSocketServer, timeoutMs?: number, logger?: ITelemetryBaseLogger): Promise<LocalDocumentDeltaConnection>;
disconnectClient(disconnectReason: string): void;
nackClient(code: number | undefined, type: NackErrorType | undefined, message: any): void;
submit(messages: IDocumentMessage[]): void;
Expand Down
2 changes: 1 addition & 1 deletion api-report/location-redirection-utils.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { IUrlResolver } from '@fluidframework/driver-definitions';
export function isLocationRedirectionError(error: any): error is ILocationRedirectionError;

// @public
export function resolveWithLocationRedirectionHandling<T>(api: (request: IRequest) => Promise<T>, request: IRequest, urlResolver: IUrlResolver, baseLogger?: ITelemetryBaseLogger): Promise<T>;
export function resolveWithLocationRedirectionHandling<T>(api: (request: IRequest) => Promise<T>, request: IRequest, urlResolver: IUrlResolver, logger?: ITelemetryBaseLogger): Promise<T>;

// (No @packageDocumentation comment for this package)

Expand Down
37 changes: 30 additions & 7 deletions api-report/telemetry-utils.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ import { TelemetryEventCategory } from '@fluidframework/core-interfaces';
import { TelemetryEventPropertyType } from '@fluidframework/core-interfaces';
import { TypedEventEmitter } from '@fluidframework/common-utils';

// @public
// @public @deprecated
export class BaseTelemetryNullLogger implements ITelemetryBaseLogger {
send(event: ITelemetryBaseEvent): void;
}

// @public
// @public @deprecated
export class ChildLogger extends TelemetryLogger {
// (undocumented)
protected readonly baseLogger: ITelemetryBaseLogger;
Expand All @@ -42,6 +42,29 @@ export type ConfigTypes = string | number | boolean | number[] | string[] | bool
export const connectedEventName = "connected";

// @public
export function createChildLogger(props?: {
logger?: ITelemetryBaseLogger;
namespace?: string;
properties?: ITelemetryLoggerPropertyBags;
}): ITelemetryLoggerExt;

// @public (undocumented)
export function createChildMonitoringContext(props: Parameters<typeof createChildLogger>[0]): MonitoringContext;

// @public
export function createDebugLogger(props: {
namespace: string;
properties?: ITelemetryLoggerPropertyBags;
}): ITelemetryLoggerExt;

// @public
export function createMultiSinkLogger(props: {
namespace?: string;
properties?: ITelemetryLoggerPropertyBags;
loggers?: (ITelemetryBaseLogger | undefined)[];
}): ITelemetryLoggerExt;

// @public @deprecated
export class DebugLogger extends TelemetryLogger {
constructor(debug: IDebugger, debugErr: IDebugger, properties?: ITelemetryLoggerPropertyBags);
static create(namespace: string, properties?: ITelemetryLoggerPropertyBags): TelemetryLogger;
Expand Down Expand Up @@ -253,9 +276,9 @@ export interface MonitoringContext<L extends ITelemetryBaseLogger = ITelemetryLo
logger: L;
}

// @public
// @public @deprecated
export class MultiSinkLogger extends TelemetryLogger {
constructor(namespace?: string, properties?: ITelemetryLoggerPropertyBags);
constructor(namespace?: string, properties?: ITelemetryLoggerPropertyBags, loggers?: ITelemetryBaseLogger[]);
addLogger(logger?: ITelemetryBaseLogger): void;
// (undocumented)
protected loggers: ITelemetryBaseLogger[];
Expand Down Expand Up @@ -330,7 +353,7 @@ export type TelemetryEventPropertyTypeExt = string | number | boolean | undefine
// @public (undocumented)
export type TelemetryEventPropertyTypes = TelemetryEventPropertyType | ITaggedTelemetryPropertyType;

// @public
// @public @deprecated
export abstract class TelemetryLogger implements ITelemetryLoggerExt {
constructor(namespace?: string | undefined, properties?: ITelemetryLoggerPropertyBags | undefined);
// (undocumented)
Expand All @@ -356,7 +379,7 @@ export abstract class TelemetryLogger implements ITelemetryLoggerExt {
}, error?: any): void;
}

// @public
// @public @deprecated
export class TelemetryNullLogger implements ITelemetryLoggerExt {
// (undocumented)
send(event: ITelemetryBaseEvent): void;
Expand All @@ -368,7 +391,7 @@ export class TelemetryNullLogger implements ITelemetryLoggerExt {
sendTelemetryEvent(event: ITelemetryGenericEvent, error?: any): void;
}

// @public
// @public @deprecated
export class TelemetryUTLogger implements ITelemetryLoggerExt {
// (undocumented)
debugAssert(condition: boolean, event?: ITelemetryErrorEvent): void;
Expand Down
4 changes: 2 additions & 2 deletions azure/packages/external-controller/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
AzureLocalConnectionConfig,
AzureRemoteConnectionConfig,
} from "@fluidframework/azure-client";
import { TelemetryNullLogger } from "@fluidframework/telemetry-utils";
import { createChildLogger } from "@fluidframework/telemetry-utils";
import { InsecureTokenProvider } from "@fluidframework/test-runtime-utils";

import { v4 as uuid } from "uuid";
Expand Down Expand Up @@ -113,7 +113,7 @@ async function initializeNewContainer(
async function start(): Promise<void> {
// Create a custom ITelemetryBaseLogger object to pass into the Tinylicious container
// and hook to the Telemetry system
const baseLogger = new TelemetryNullLogger();
const baseLogger = createChildLogger();

// Wrap telemetry logger for use with Devtools
const devtoolsLogger = new DevtoolsLogger(baseLogger);
Expand Down
5 changes: 3 additions & 2 deletions azure/packages/test/scenario-runner/src/TestOrchestrator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ import * as fs from "node:fs";
import * as yaml from "js-yaml";
import { v4 as uuid } from "uuid";

import { PerformanceEvent, TelemetryLogger } from "@fluidframework/telemetry-utils";
import { PerformanceEvent } from "@fluidframework/telemetry-utils";

import { ITelemetryLogger } from "@fluidframework/core-interfaces";
import { AzureClientRunner, AzureClientRunnerConfig } from "./AzureClientRunner";
import { DocCreatorRunner, DocCreatorRunnerConfig } from "./DocCreatorRunner";
import { DocLoaderRunner, DocLoaderRunnerConfig } from "./DocLoaderRunner";
Expand Down Expand Up @@ -110,7 +111,7 @@ export class TestOrchestrator {
return success;
}

private async execRun(logger: TelemetryLogger): Promise<boolean> {
private async execRun(logger: ITelemetryLogger): Promise<boolean> {
if (!this.doc) {
throw new Error("Invalid config.");
}
Expand Down
21 changes: 13 additions & 8 deletions azure/packages/test/scenario-runner/src/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ import fs from "fs";
import { ITelemetryBaseEvent } from "@fluidframework/common-definitions";
import { assert } from "@fluidframework/common-utils";
import { LazyPromise } from "@fluidframework/core-utils";
import { ChildLogger, TelemetryLogger } from "@fluidframework/telemetry-utils";
import { createChildLogger, TelemetryLogger } from "@fluidframework/telemetry-utils";
import { ITelemetryBufferedLogger } from "@fluidframework/test-driver-definitions";

import { ITelemetryLogger } from "@fluidframework/core-interfaces";
import { pkgName, pkgVersion } from "./packageVersion";

export interface LoggerConfig {
Expand Down Expand Up @@ -120,20 +121,24 @@ export async function getLogger(
config: LoggerConfig,
events?: string[],
transformEvents?: Map<string, string>,
): Promise<TelemetryLogger> {
): Promise<ITelemetryLogger> {
const baseLogger = await loggerP;
if (events) {
baseLogger.registerExpectedEvent(events);
}
if (transformEvents) {
baseLogger.transformEvents(transformEvents);
}
return ChildLogger.create(baseLogger, config.namespace, {
all: {
runId: config.runId,
scenarioName: config.scenarioName,
endpoint: config.endpoint,
region: config.region,
return createChildLogger({
logger: baseLogger,
namespace: config.namespace,
properties: {
all: {
runId: config.runId,
scenarioName: config.scenarioName,
endpoint: config.endpoint,
region: config.region,
},
},
});
}
4 changes: 2 additions & 2 deletions azure/packages/test/scenario-runner/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@ import {
} from "@fluidframework/azure-client";
import { ContainerSchema, IFluidContainer } from "@fluidframework/fluid-static";
import { SharedMap } from "@fluidframework/map";
import { TelemetryLogger } from "@fluidframework/telemetry-utils";
import { InsecureTokenProvider } from "@fluidframework/test-runtime-utils";

import { v4 as uuid } from "uuid";

import { ITelemetryLogger } from "@fluidframework/core-interfaces";
import { ContainerFactorySchema } from "./interface";

export interface AzureClientConfig {
connType: string;
connEndpoint?: string;
userId?: string;
userName?: string;
logger?: TelemetryLogger;
logger?: ITelemetryLogger;
tenantId?: string;
tenantKey?: string;
functionUrl?: string;
Expand Down
4 changes: 2 additions & 2 deletions experimental/dds/tree/src/Checkout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/

import { assert } from '@fluidframework/common-utils';
import { ChildLogger, EventEmitterWithErrorHandling, ITelemetryLoggerExt } from '@fluidframework/telemetry-utils';
import { EventEmitterWithErrorHandling, ITelemetryLoggerExt, createChildLogger } from '@fluidframework/telemetry-utils';
import { IErrorEvent } from '@fluidframework/common-definitions';
import { IDisposable, ITelemetryProperties } from '@fluidframework/core-interfaces';
import { assertWithMessage, fail, RestOrArray, unwrapRestOrArray } from './Common';
Expand Down Expand Up @@ -125,7 +125,7 @@ export abstract class Checkout extends EventEmitterWithErrorHandling<ICheckoutEv
this.tree.emit('error', error);
});
this.tree = tree;
this.logger = ChildLogger.create(this.tree.logger, 'Checkout');
this.logger = createChildLogger({ logger: this.tree.logger, namespace: 'Checkout' });
if (tree.logViewer instanceof CachingLogViewer) {
this.cachingLogViewer = tree.logViewer;
}
Expand Down
18 changes: 11 additions & 7 deletions experimental/dds/tree/src/SharedTree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {
import { ITelemetryProperties } from '@fluidframework/core-interfaces';
import {
ITelemetryLoggerExt,
ChildLogger,
createChildLogger,
ITelemetryLoggerPropertyBags,
PerformanceEvent,
} from '@fluidframework/telemetry-utils';
Expand Down Expand Up @@ -547,12 +547,16 @@ export class SharedTree extends SharedObject<ISharedTreeEvents> implements NodeI
const historyPolicy = this.getHistoryPolicy(options);
this.summarizeHistory = historyPolicy.summarizeHistory;

this.logger = ChildLogger.create(runtime.logger, 'SharedTree', sharedTreeTelemetryProperties);
this.sequencedEditAppliedLogger = ChildLogger.create(
this.logger,
'SequencedEditApplied',
sharedTreeTelemetryProperties
);
this.logger = createChildLogger({
logger: runtime.logger,
namespace: 'SharedTree',
properties: sharedTreeTelemetryProperties,
});
this.sequencedEditAppliedLogger = createChildLogger({
logger: this.logger,
namespace: 'SequencedEditApplied',
properties: sharedTreeTelemetryProperties,
});

const attributionId = (options as SharedTreeOptions<WriteFormat.v0_1_1>).attributionId;
this.idCompressor = new IdCompressor(
Expand Down
4 changes: 2 additions & 2 deletions experimental/dds/tree/src/id-compressor/Logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Licensed under the MIT License.
*/

import { ITelemetryLoggerExt, TelemetryNullLogger } from '@fluidframework/telemetry-utils';
import { ITelemetryLoggerExt, createChildLogger } from '@fluidframework/telemetry-utils';

/**
* Because the IdCompressor emits so much telemetry, this function is used to sample
Expand All @@ -18,5 +18,5 @@ export function createThrottledIdCompressorLogger(
percentage: number
): ITelemetryLoggerExt {
const sendEvents = Math.random() < percentage;
return sendEvents ? logger : new TelemetryNullLogger();
return sendEvents ? logger : createChildLogger();
}
4 changes: 2 additions & 2 deletions experimental/dds/tree/src/test/utilities/TestUtilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import type { IContainer, IHostLoader } from '@fluidframework/container-definiti
import type { IFluidCodeDetails, IFluidHandle, IRequestHeader } from '@fluidframework/core-interfaces';
import { ISequencedDocumentMessage } from '@fluidframework/protocol-definitions';
import { IContainerRuntimeBase } from '@fluidframework/runtime-definitions';
import { ConfigTypes, IConfigProviderBase, TelemetryNullLogger } from '@fluidframework/telemetry-utils';
import { ConfigTypes, IConfigProviderBase, createChildLogger } from '@fluidframework/telemetry-utils';
import { ITelemetryBaseLogger, IRequest } from '@fluidframework/core-interfaces';
import {
AttributionId,
Expand Down Expand Up @@ -667,7 +667,7 @@ export function spyOnSubmittedOps<Op extends SharedTreeOp | SharedTreeOp_0_0_2>(
*/
export async function waitForSummary(mainContainer: IContainer): Promise<string> {
const { deltaManager } = mainContainer;
const summaryCollection = new SummaryCollection(deltaManager, new TelemetryNullLogger());
const summaryCollection = new SummaryCollection(deltaManager, createChildLogger());
const ackedSummary = await summaryCollection.waitSummaryAck(deltaManager.lastSequenceNumber);
return ackedSummary.summaryAck.contents.handle;
}
Expand Down
4 changes: 2 additions & 2 deletions packages/dds/matrix/src/permutationvector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/

import { assert } from "@fluidframework/common-utils";
import { ChildLogger } from "@fluidframework/telemetry-utils";
import { createChildLogger } from "@fluidframework/telemetry-utils";
import {
IFluidDataStoreRuntime,
IChannelStorageService,
Expand Down Expand Up @@ -136,7 +136,7 @@ export class PermutationVector extends Client {
) {
super(
PermutationSegment.fromJSONObject,
ChildLogger.create(logger, `Matrix.${path}.MergeTreeClient`),
createChildLogger({ logger, namespace: `Matrix.${path}.MergeTreeClient` }),
{
...runtime.options,
newMergeTreeSnapshotFormat: true, // Temporarily force new snapshot format until it is the default.
Expand Down
4 changes: 2 additions & 2 deletions packages/dds/merge-tree/src/snapshotLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import { assert, bufferToString } from "@fluidframework/common-utils";
import { IFluidSerializer } from "@fluidframework/shared-object-base";
import { ChildLogger, ITelemetryLoggerExt } from "@fluidframework/telemetry-utils";
import { createChildLogger, ITelemetryLoggerExt } from "@fluidframework/telemetry-utils";
import { ISequencedDocumentMessage } from "@fluidframework/protocol-definitions";
import {
IFluidDataStoreRuntime,
Expand All @@ -34,7 +34,7 @@ export class SnapshotLoader {
logger: ITelemetryLoggerExt,
private readonly serializer: IFluidSerializer,
) {
this.logger = ChildLogger.create(logger, "SnapshotLoader");
this.logger = createChildLogger({ logger, namespace: "SnapshotLoader" });
}

public async initialize(
Expand Down
4 changes: 2 additions & 2 deletions packages/dds/merge-tree/src/snapshotV1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Licensed under the MIT License.
*/

import { ITelemetryLoggerExt, ChildLogger } from "@fluidframework/telemetry-utils";
import { ITelemetryLoggerExt, createChildLogger } from "@fluidframework/telemetry-utils";
import { IFluidHandle } from "@fluidframework/core-interfaces";
import { IFluidSerializer } from "@fluidframework/shared-object-base";
import { assert, bufferToString } from "@fluidframework/common-utils";
Expand Down Expand Up @@ -49,7 +49,7 @@ export class SnapshotV1 {
public filename?: string,
public onCompletion?: () => void,
) {
this.logger = ChildLogger.create(logger, "Snapshot");
this.logger = createChildLogger({ logger, namespace: "Snapshot" });
this.chunkSize = mergeTree?.options?.mergeTreeSnapshotChunkSize ?? SnapshotV1.chunkSize;

const { currentSeq, minSeq } = mergeTree.collabWindow;
Expand Down
4 changes: 2 additions & 2 deletions packages/dds/merge-tree/src/snapshotlegacy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

/* eslint-disable @typescript-eslint/no-non-null-assertion */

import { ITelemetryLoggerExt, ChildLogger } from "@fluidframework/telemetry-utils";
import { ITelemetryLoggerExt, createChildLogger } from "@fluidframework/telemetry-utils";
import { assert } from "@fluidframework/common-utils";
import { IFluidHandle } from "@fluidframework/core-interfaces";
import { IFluidSerializer } from "@fluidframework/shared-object-base";
Expand Down Expand Up @@ -61,7 +61,7 @@ export class SnapshotLegacy {
public filename?: string,
public onCompletion?: () => void,
) {
this.logger = ChildLogger.create(logger, "Snapshot");
this.logger = createChildLogger({ logger, namespace: "Snapshot" });
this.chunkSize =
mergeTree?.options?.mergeTreeSnapshotChunkSize ?? SnapshotLegacy.sizeOfFirstChunk;
}
Expand Down
4 changes: 2 additions & 2 deletions packages/dds/merge-tree/src/test/beastTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import fs from "fs";
import path from "path";
import { IRandom, makeRandom } from "@fluid-internal/stochastic-test-utils";
import { Trace } from "@fluidframework/common-utils";
import { DebugLogger } from "@fluidframework/telemetry-utils";
import { createDebugLogger } from "@fluidframework/telemetry-utils";
import { ISequencedDocumentMessage } from "@fluidframework/protocol-definitions";
import JsDiff from "diff";
import {
Expand Down Expand Up @@ -1373,7 +1373,7 @@ export function TestPack(verbose = true) {
}
}
const segs = <SharedStringJSONSegment[]>(
new SnapshotLegacy(cli.mergeTree, DebugLogger.create("fluid:snapshot"))
new SnapshotLegacy(cli.mergeTree, createDebugLogger({ namespace: "fluid:snapshot" }))
.extractSync()
.map((seg) => seg.toJSONObject() as JsonSegmentSpecs)
);
Expand Down
Loading