or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

ai.mdanalytics.mdapp-check.mdauth-guard.mdauthentication.mddata-connect.mddatabase.mdfirebase-app.mdfirestore.mdfunctions.mdindex.mdmessaging.mdperformance.mdremote-config.mdstorage.mdvertexai.md
tile.json

performance.mddocs/

Performance Monitoring

Firebase Performance Monitoring helps monitor your app's performance with automatic and custom performance traces.

Capabilities

Standalone Provider

export function providePerformance(fn: () => Performance): EnvironmentProviders;
export function getPerformance(app?: FirebaseApp): Performance;

Angular Services

export class Performance extends Performance {}
export class PerformanceInstances extends Array<Performance> {}
export const performanceInstance$: Observable<Performance>;

Performance Functions

/**
 * Create custom performance trace
 * @param performance - Performance instance
 * @param name - Trace name
 * @returns Performance trace
 */
export function trace(performance: Performance, name: string): Trace;

/**
 * Check if Performance Monitoring is supported
 * @returns Promise resolving to support status
 */
export function isSupported(): Promise<boolean>;

interface Trace {
  start(): void;
  stop(): void;
  putAttribute(name: string, value: string): void;
  getAttribute(name: string): string | undefined;
  removeAttribute(name: string): void;
  getAttributes(): { [key: string]: string };
  putMetric(name: string, value: number): void;
  getMetric(name: string): number;
  incrementMetric(name: string, value?: number): void;
}

Usage Examples

import { Component, inject } from '@angular/core';
import { Performance, trace } from '@angular/fire/performance';

@Component({
  selector: 'app-performance',
  template: `...`,
})
export class PerformanceComponent {
  private performance = inject(Performance);

  async performExpensiveOperation() {
    const customTrace = trace(this.performance, 'expensive_operation');
    customTrace.start();
    
    try {
      // Perform the operation
      const result = await this.doExpensiveWork();
      
      customTrace.putAttribute('success', 'true');
      customTrace.putMetric('items_processed', result.length);
      
      return result;
    } catch (error) {
      customTrace.putAttribute('success', 'false');
      customTrace.putAttribute('error', error.message);
      throw error;
    } finally {
      customTrace.stop();
    }
  }
  
  private async doExpensiveWork() {
    // Simulate expensive operation
    return new Promise(resolve => {
      setTimeout(() => resolve([1, 2, 3, 4, 5]), 2000);
    });
  }
}