Skip to content

feat(perf): Add performance measuring api #117

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

Open
wants to merge 38 commits into
base: master
Choose a base branch
from
Open

Conversation

TatianaFomina
Copy link

@TatianaFomina TatianaFomina commented Mar 15, 2025

Performance Monitoring API

This PR adds a new Performance Monitoring API to track application performance metrics.

Features

  • Track transactions and spans with timing data
  • Automatic span completion when transaction ends
  • Support for both browser and Node.js environments
  • Debug mode for development
  • Graceful cleanup on page unload/process exit

API

// Start a transaction
const transaction = hawk.startTransaction('page-load', {
  page: '/home',
  type: 'navigation'
});

// Create spans within transaction
const span = hawk.startSpan(transaction.id, 'api-call', {
  url: '/api/users'
});

// Finish span when operation completes
span.finish();

// Finish transaction
transaction.finish();

@TatianaFomina TatianaFomina changed the title Feat/perf feat(perf): Add performance measuring api Mar 15, 2025
neSpecc and others added 14 commits March 16, 2025 15:49
…ant for the token and remove unused transaction generation buttons for improved clarity and performance.
…for transactions. Update documentation and README to reflect new settings, including changes to transaction filtering criteria. Remove unused demo elements from example HTML for improved clarity.
…sistency and improving documentation clarity. Update comments to enhance understanding of methods and parameters.
…pan and Transaction classes, including descriptions for properties and methods. Remove unused types from performance module and update imports for better clarity and organization.
…readability. Adjust formatting for better alignment and clarity, and update import statements for consistency.
@TatianaFomina TatianaFomina requested a review from neSpecc March 16, 2025 20:07
*
* @param transaction - Transaction to queue
*/
public queueTransaction(transaction: Transaction): void {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public queueTransaction(transaction: Transaction): void {
public enqueueTransaction(transaction: Transaction): void {

if (this.sendQueue.length > 0) {
void this.processSendQueue();
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sendRetires should be cleared as well

* @param p - Percentile to calculate (e.g., 50 for median, 95 for 95th percentile)
* @returns Percentile value
*/
private percentile(sortedValues: number[], p: number): number {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move to util, please

* @param p - Percentile to calculate (e.g., 50 for median, 95 for 95th percentile)
* @returns Percentile value
*/
private percentile(sortedValues: number[], p: number): number {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe sorting should be a part of this method?

* @param values - Array of numbers
* @returns Average value
*/
private average(values: number[]): number {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

create utility


this.sendRetries.set(tx.id, retryCount);

const shouldRetry = retryCount <= MAX_SEND_RETRIES;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think retrying should be a part of Transport

/**
* Queues this transaction for sending to the server
*/
private queueForSending(): void {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
private queueForSending(): void {
private enqueueForSending(): void {

@@ -161,3 +161,154 @@ const hawk = new HawkCatcher({

hawk.connectVue(Vue)
```

## Performance Monitoring

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • explain what is Transaction and Span.
  • move API Reference on the first place
  • optimization explanation is a technical detail, so it should be placed after usage description

/**
* Total number of transactions in this group
*/
count: number;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move count under name

token: this.token,
catcherType: 'performance',
payload: {
transactions,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets rename to aggregatedTransactions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants