/*! * Copyright (c) Microsoft Corporation and contributors. All rights reserved. * Licensed under the MIT License. */ import type { TelemetryLoggerExt } from "./telemetryTypesUndeprecated.js"; /** * An object that contains a callback used in conjunction with the {@link createSampledLogger} utility function to provide custom logic for sampling events. * * @internal */ export interface IEventSampler { /** * @returns true if the event should be sampled or false if not */ sample: () => boolean; } /** * A telemetry logger that has sampling capabilities * * @internal */ export interface ISampledTelemetryLogger extends TelemetryLoggerExt { /** * Indicates if the feature flag to disable sampling is set. * * @remarks Exposed to enable some advanced scenarios where the code using the sampled logger * could take advantage of skipping the execution of some logic when it can determine * it won't be necessary because the telemetry event that needs it wouldn't be * emitted anyway. */ isSamplingDisabled: boolean; } /** * Wraps around an existing logger matching the {@link TelemetryLoggerExt} interface and provides the ability to only log a subset of events using a sampling strategy provided by an {@link IEventSampler}. * You can chose to not provide an event sampler which is effectively a no-op, meaning that it will be treated as if the sampler always returns true. * * @remarks * The sampling functionality uses the Fluid telemetry logging configuration along with the optionally provided event sampling callback to determine whether an event should * be logged or not. * * Configuration object parameters: * 'Fluid.Telemetry.DisableSampling': if this config value is set to true, all events will be unsampled and therefore logged. * Otherwise only a sample will be logged according to the provided event sampler callback. * * Note that the same sampler is used for all APIs of the returned logger. If you want separate events flowing through the returned logger to be sampled separately, the {@link IEventSampler} you provide should track them separately. * * @internal */ export declare function createSampledLogger(logger: TelemetryLoggerExt, eventSampler?: IEventSampler, skipLoggingWhenSamplingIsDisabled?: boolean): ISampledTelemetryLogger; /** * Runs the specified function and returns an object with the time it took to run as well as any output from it. * @remarks Useful in conjunction with {@link TelemetryEventBatcher}. * * @param codeToMeasure - The code to be executed and measured. * @returns The total duration of the code execution and whatever the passed-in code block returns. * @internal */ export declare function measure(codeToMeasure: () => T): { duration: number; output: T; }; //# sourceMappingURL=utils.d.ts.map