diff --git a/packages/opencensus-core/src/exporters/console-exporter.ts b/packages/opencensus-core/src/exporters/console-exporter.ts index 7eca6d0a3..d01a31bc4 100644 --- a/packages/opencensus-core/src/exporters/console-exporter.ts +++ b/packages/opencensus-core/src/exporters/console-exporter.ts @@ -96,4 +96,12 @@ export class ConsoleStatsExporter implements types.StatsEventListener { onRecord(views: View[], measurement: Measurement) { console.log(`Measurement recorded: ${measurement.measure.name}`); } + + /** + * Starts the Console exporter that polls Metric from Metrics library and + * shows in the log console.. + */ + start(): void { + // TODO(mayurkale): dependency with PR#253. + } } diff --git a/packages/opencensus-core/src/exporters/types.ts b/packages/opencensus-core/src/exporters/types.ts index c7f0f511f..ff08dc74d 100644 --- a/packages/opencensus-core/src/exporters/types.ts +++ b/packages/opencensus-core/src/exporters/types.ts @@ -34,15 +34,23 @@ export interface Exporter extends modelTypes.SpanEventListener { export interface StatsEventListener { /** * Is called whenever a new view is registered + * @deprecated since version 0.0.9 - use {@link start} instead * @param view The registered view */ onRegisterView(view: View): void; /** * Is called whenever a new measurement is recorded. + * @deprecated since version 0.0.9 - use {@link start} instead * @param views The views related to the measurement * @param measurement The recorded measurement */ onRecord(views: View[], measurement: Measurement): void; + + /** + * Starts the exporter that polls Metric from Metrics library and send + * batched data to backend. + */ + start(): void; } export type ExporterConfig = configTypes.BufferConfig; diff --git a/packages/opencensus-core/src/stats/stats.ts b/packages/opencensus-core/src/stats/stats.ts index 9696453ee..89826c26e 100644 --- a/packages/opencensus-core/src/stats/stats.ts +++ b/packages/opencensus-core/src/stats/stats.ts @@ -90,6 +90,10 @@ export class Stats { exporter.onRegisterView(view); } } + + // dependency with PR#253 and once start method is implemented in all stats + // exporters + // exporter.start(); } /** diff --git a/packages/opencensus-core/test/test-stats.ts b/packages/opencensus-core/test/test-stats.ts index 9da9c6e73..f96004224 100644 --- a/packages/opencensus-core/test/test-stats.ts +++ b/packages/opencensus-core/test/test-stats.ts @@ -30,6 +30,10 @@ class TestExporter implements StatsEventListener { this.recordedMeasurements.push(measurement); } + start(): void { + // TODO(mayurkale): dependency with PR#253. + } + clean() { this.registeredViews = []; this.recordedMeasurements = []; diff --git a/packages/opencensus-exporter-prometheus/src/prometheus-stats.ts b/packages/opencensus-exporter-prometheus/src/prometheus-stats.ts index 87844b5c6..d3d6b353f 100644 --- a/packages/opencensus-exporter-prometheus/src/prometheus-stats.ts +++ b/packages/opencensus-exporter-prometheus/src/prometheus-stats.ts @@ -84,6 +84,15 @@ export class PrometheusStatsExporter implements StatsEventListener { } } + /** + * Starts the Prometheus exporter that polls Metric from Metrics library and + * send batched data to backend. + */ + start(): void { + // TODO(mayurkale): add setInterval here to poll Metric, transform and send + // // it to backend (dependency with PR#253). + } + /** * Register or get a metric in Prometheus * @param view View will be used to register the metric diff --git a/packages/opencensus-exporter-stackdriver/src/stackdriver-monitoring.ts b/packages/opencensus-exporter-stackdriver/src/stackdriver-monitoring.ts index 543a1673a..b74eb5cee 100644 --- a/packages/opencensus-exporter-stackdriver/src/stackdriver-monitoring.ts +++ b/packages/opencensus-exporter-stackdriver/src/stackdriver-monitoring.ts @@ -97,6 +97,15 @@ export class StackdriverStatsExporter implements StatsEventListener { } } + /** + * Starts the Stackdriver exporter that polls Metric from Metrics library and + * send batched data to backend. + */ + start(): void { + // TODO(mayurkale): add setInterval here to poll Metric, transform and send + // // it to backend (dependency with PR#253). + } + /** * Clear the interval timer to stop uploading metrics. It should be called * whenever the exporter is not needed anymore. diff --git a/packages/opencensus-exporter-zpages/src/zpages.ts b/packages/opencensus-exporter-zpages/src/zpages.ts index 31e312f11..772d80426 100644 --- a/packages/opencensus-exporter-zpages/src/zpages.ts +++ b/packages/opencensus-exporter-zpages/src/zpages.ts @@ -127,6 +127,10 @@ export class ZpagesExporter implements Exporter, StatsEventListener { }); } + start(): void { + // TODO(mayurkale): dependency with PR#253. + } + /** * Send a trace to traces array * @param trace the rootSpan to be sent to the array list