Skip to content

Commit

Permalink
Add telemetry to mixinattributor (#15033)
Browse files Browse the repository at this point in the history
  • Loading branch information
clarenceli-msft authored Apr 21, 2023
1 parent 118900c commit 7796557
Showing 1 changed file with 29 additions and 7 deletions.
36 changes: 29 additions & 7 deletions packages/framework/attributor/src/mixinAttributor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ import { IContainerRuntime } from "@fluidframework/container-runtime-definitions
import { IRequest, IResponse, FluidObject } from "@fluidframework/core-interfaces";
import { assert, bufferToString, unreachableCase } from "@fluidframework/common-utils";
import { UsageError } from "@fluidframework/container-utils";
import { loggerToMonitoringContext } from "@fluidframework/telemetry-utils";
import {
ChildLogger,
PerformanceEvent,
loggerToMonitoringContext,
} from "@fluidframework/telemetry-utils";
import { Attributor, IAttributor, OpStreamAttributor } from "./attributor";
import { AttributorSerializer, chain, deltaEncoder, Encoder } from "./encoders";
import { makeLZ4Encoder } from "./lz4Encoder";
Expand Down Expand Up @@ -131,6 +135,7 @@ export const mixinAttributor = (Base: typeof ContainerRuntime = ContainerRuntime
);

const mc = loggerToMonitoringContext(context.taggedLogger);

const shouldTrackAttribution = mc.config.getBoolean(enableOnNewFileKey) ?? false;
if (shouldTrackAttribution) {
(context.options.attribution ??= {}).track = true;
Expand All @@ -147,17 +152,34 @@ export const mixinAttributor = (Base: typeof ContainerRuntime = ContainerRuntime
)) as ContainerRuntimeWithAttributor;
runtime.runtimeAttributor = runtimeAttributor as RuntimeAttributor;

const logger = ChildLogger.create(runtime.logger, "Attributor");

// Note: this fetches attribution blobs relatively eagerly in the load flow; we may want to optimize
// this to avoid blocking on such information until application actually requests some op-based attribution
// info or we need to summarize. All that really needs to happen immediately is to start recording
// op seq# -> attributionInfo for new ops.
await runtime.runtimeAttributor.initialize(
deltaManager,
audience,
baseSnapshot,
async (id) => runtime.storage.readBlob(id),
shouldTrackAttribution,
await PerformanceEvent.timedExecAsync(
logger,
{
eventName: "initialize",
},
async (event) => {
void runtime.runtimeAttributor?.initialize(
deltaManager,
audience,
baseSnapshot,
async (id) => runtime.storage.readBlob(id),
shouldTrackAttribution,
);
event.end({
attributionEnabledInConfig: shouldTrackAttribution,
attributionEnabledInDoc: runtime.runtimeAttributor
? runtime.runtimeAttributor.isEnabled
: false,
});
},
);

return runtime;
}

Expand Down

0 comments on commit 7796557

Please sign in to comment.