Skip to content

Commit

Permalink
fix: updates ValueRecorder to allow negative values (open-telemetry#1373
Browse files Browse the repository at this point in the history
)
  • Loading branch information
michaelgoin authored and dyladan committed Feb 18, 2021
1 parent a1e3373 commit 835c2ee
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 47 deletions.
13 changes: 0 additions & 13 deletions api/src/metrics/BoundInstrument.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@
* limitations under the License.
*/

import { CorrelationContext } from '../correlation_context/CorrelationContext';
import { SpanContext } from '../trace/span_context';

/** An Instrument for Counter Metric. */
export interface BoundCounter {
/**
Expand All @@ -31,18 +28,8 @@ export interface BoundValueRecorder {
/**
* Records the given value to this value recorder.
* @param value to record.
* @param correlationContext the correlationContext associated with the
* values.
* @param spanContext the {@link SpanContext} that identifies the {@link Span}
* which the values are associated with.
*/
record(value: number): void;
record(value: number, correlationContext: CorrelationContext): void;
record(
value: number,
correlationContext: CorrelationContext,
spanContext: SpanContext
): void;
}

/** An Instrument for Base Observer */
Expand Down
21 changes: 0 additions & 21 deletions api/src/metrics/Metric.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
* limitations under the License.
*/

import { CorrelationContext } from '../correlation_context/CorrelationContext';
import { SpanContext } from '../trace/span_context';
import {
BoundBaseObserver,
BoundCounter,
Expand Down Expand Up @@ -51,12 +49,6 @@ export interface MetricOptions {
*/
disabled?: boolean;

/**
* (Measure only, default true) Asserts that this metric will only accept
* non-negative values (e.g. disk usage).
*/
absolute?: boolean;

/**
* Indicates the type of the recorded value.
* @default {@link ValueType.DOUBLE}
Expand Down Expand Up @@ -148,19 +140,6 @@ export interface ValueRecorder extends UnboundMetric<BoundValueRecorder> {
* Records the given value to this value recorder.
*/
record(value: number, labels?: Labels): void;

record(
value: number,
labels: Labels,
correlationContext: CorrelationContext
): void;

record(
value: number,
labels: Labels,
correlationContext: CorrelationContext,
spanContext: SpanContext
): void;
}

/** Base interface for the Observer metrics. */
Expand Down
15 changes: 2 additions & 13 deletions api/src/metrics/NoopMeter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,19 +142,8 @@ export class NoopCounterMetric
export class NoopValueRecorderMetric
extends NoopMetric<BoundValueRecorder>
implements ValueRecorder {
record(
value: number,
labels: Labels,
correlationContext?: CorrelationContext,
spanContext?: SpanContext
) {
if (typeof correlationContext === 'undefined') {
this.bind(labels).record(value);
} else if (typeof spanContext === 'undefined') {
this.bind(labels).record(value, correlationContext);
} else {
this.bind(labels).record(value, correlationContext, spanContext);
}
record(value: number, labels: Labels) {
this.bind(labels).record(value);
}
}

Expand Down

0 comments on commit 835c2ee

Please sign in to comment.