Skip to content

Commit

Permalink
Metrics updates (open-telemetry#1700)
Browse files Browse the repository at this point in the history
* feat: renaming batcher to processor, fixing aggregators, adding missing metrics in api

* chore: fixing metrics in exporter collector, updated tests, fixing observer result

* chore: refactoring tests for rest of collectors

* chore: fixing monotonic sum observer, updated test to cover that scenario correctly
  • Loading branch information
obecny authored and dyladan committed Feb 18, 2021
1 parent 514492f commit 39d4ba3
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 0 deletions.
26 changes: 26 additions & 0 deletions api/src/metrics/Meter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import {
BatchObserver,
BatchMetricOptions,
UpDownCounter,
SumObserver,
UpDownSumObserver,
} from './Metric';
import { ObserverResult } from './ObserverResult';

Expand Down Expand Up @@ -81,6 +83,30 @@ export interface Meter {
callback?: (observerResult: ObserverResult) => void
): ValueObserver;

/**
* Creates a new `SumObserver` metric.
* @param name the name of the metric.
* @param [options] the metric options.
* @param [callback] the observer callback
*/
createSumObserver(
name: string,
options?: MetricOptions,
callback?: (observerResult: ObserverResult) => void
): SumObserver;

/**
* Creates a new `UpDownSumObserver` metric.
* @param name the name of the metric.
* @param [options] the metric options.
* @param [callback] the observer callback
*/
createUpDownSumObserver(
name: string,
options?: MetricOptions,
callback?: (observerResult: ObserverResult) => void
): UpDownSumObserver;

/**
* Creates a new `BatchObserver` metric, can be used to update many metrics
* at the same time and when operations needs to be async
Expand Down
29 changes: 29 additions & 0 deletions api/src/metrics/NoopMeter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import {
BatchObserver,
UpDownCounter,
BaseObserver,
UpDownSumObserver,
} from './Metric';
import {
BoundValueRecorder,
Expand Down Expand Up @@ -84,6 +85,34 @@ export class NoopMeter implements Meter {
return NOOP_VALUE_OBSERVER_METRIC;
}

/**
* Returns constant noop sum observer.
* @param name the name of the metric.
* @param [options] the metric options.
* @param [callback] the sum observer callback
*/
createSumObserver(
_name: string,
_options?: MetricOptions,
_callback?: (observerResult: ObserverResult) => void
): ValueObserver {
return NOOP_SUM_OBSERVER_METRIC;
}

/**
* Returns constant noop up down sum observer.
* @param name the name of the metric.
* @param [options] the metric options.
* @param [callback] the up down sum observer callback
*/
createUpDownSumObserver(
_name: string,
_options?: MetricOptions,
_callback?: (observerResult: ObserverResult) => void
): UpDownSumObserver {
return NOOP_UP_DOWN_SUM_OBSERVER_METRIC;
}

/**
* Returns constant noop batch observer.
* @param name the name of the metric.
Expand Down

0 comments on commit 39d4ba3

Please sign in to comment.