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

Added performance attributes #509

Closed
wants to merge 3 commits 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
20 changes: 10 additions & 10 deletions package-lock.json

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

111 changes: 111 additions & 0 deletions packages/performance/src/definitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,76 @@ export interface FirebasePerformancePlugin {
* @since 0.1.0
*/
isEnabled(): Promise<IsEnabledResult>;

// [+] Issue 505: adding start/stop params
/**
* Records a trace from given parameters. This provides a direct way to use trace without a need to start/stop.
* This is useful for use cases in which the trace cannot directly be used
* (e.g. if the duration was captured before the Performance SDK was loaded).
*
* @param startTime - The start time of the trace in milliseconds since the epoch.
* @param duration - The duration of the trace in milliseconds.
* @param options - Additional options for recording the trace.
* @since 0.1.0
*/
// [+] Issue 505: adding record
record(
startTime: number,
duration: number,
options?: RecordOptions
): void;

// [+] Issue 505: getAttribute
/**
* Retrieves the value which a custom attribute is set to.
*
* @param attr - The name of the custom attribute.
* @returns The value of the custom attribute, or `undefined` if not set.
* @since 0.1.0
*/
getAttribute(attr: string): string | undefined;


// [+] Issue 505: getAttributes
/**
* Returns a map of all custom attributes of a trace instance.
*
* @returns A map of custom attributes where keys are attribute names and values are attribute values.
* @since 0.1.0
*/
getAttributes(): { [key: string]: string };

// [+] Issue 505: removeAttribute
/**
* Removes the specified custom attribute from a trace instance.
*
* @param attr - The name of the custom attribute to be removed.
* @since 0.1.0
*/
removeAttribute(attr: string): void;

// [+] Issue 505: putMetric
/**
* Sets the value of the specified custom metric to the given number.
* The value will be floored down to an integer.
*
* @param metricName - The name of the custom metric.
* @param num - The value to set for the custom metric.
* @since 0.1.0
*/
putMetric(metricName: string, num: number): void;

// [+] Issue 505: getMetric
/**
* Returns the value of the custom metric by that name.
* If a custom metric with that name does not exist, it will return zero.
*
* @param metricName - The name of the custom metric.
* @returns The value of the custom metric, or zero if not set.
* @since 0.1.0
*/
getMetric(metricName: string): number;

}

/**
Expand Down Expand Up @@ -105,3 +175,44 @@ export interface IsEnabledResult {
*/
enabled: boolean;
}

// [+] Issue 505: RecordOptions Interface
export interface RecordOptions {
/**
* Custom metrics associated with the trace.
* @since 0.1.0
*/
metrics?: { [key: string]: number };

/**
* Custom attributes associated with the trace.
* @since 0.1.0
*/
attributes?: { [key: string]: string };

/**
* Additional attribute to be added to the trace.
* @since 0.1.0
*/
putAttribute?: PutAttributeOptions;
}

/**
* Options for adding a custom attribute.
* @since 0.1.0
*/

// [+] Issue 505: PutAttributeOptions Interface
export interface PutAttributeOptions {
/**
* Name of the attribute to be added.
* @since 0.1.0
*/
attributeName: string;

/**
* Value of the attribute to be added.
* @since 0.1.0
*/
attributeValue: string;
}