/** * @flow * Trace representation wrapper */ import { getNativeModule } from '../../utils/native'; import type PerformanceMonitoring from './'; export default class Trace { identifier: string; _perf: PerformanceMonitoring; constructor(perf: PerformanceMonitoring, identifier: string) { this._perf = perf; this.identifier = identifier; } getAttribute(attribute: string): Promise { return getNativeModule(this._perf).getTraceAttribute( this.identifier, attribute ); } getAttributes(): Promise { return getNativeModule(this._perf).getTraceAttributes(this.identifier); } getMetric(metricName: string): Promise { return getNativeModule(this._perf).getTraceLongMetric( this.identifier, metricName ); } incrementMetric(metricName: string, incrementBy: number): Promise { return getNativeModule(this._perf).incrementTraceMetric( this.identifier, metricName, incrementBy ); } putAttribute(attribute: string, value: string): Promise { return getNativeModule(this._perf).putTraceAttribute( this.identifier, attribute, value ); } putMetric(metricName: string, value: number): Promise { return getNativeModule(this._perf).putTraceMetric( this.identifier, metricName, value ); } removeAttribute(attribute: string): Promise { return getNativeModule(this._perf).removeTraceAttribute( this.identifier, attribute ); } start(): Promise { return getNativeModule(this._perf).startTrace(this.identifier); } stop(): Promise { return getNativeModule(this._perf).stopTrace(this.identifier); } }