-
Notifications
You must be signed in to change notification settings - Fork 821
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d75004a
commit 1e29d9d
Showing
4 changed files
with
58 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/*! | ||
* Copyright 2019, OpenTelemetry Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import * as api from '@opentelemetry/api'; | ||
import { Resource } from '@opentelemetry/resources'; | ||
import { BoundUpDownCounter } from './BoundInstrument'; | ||
import { MetricOptions } from './types'; | ||
import { MetricKind } from './export/types'; | ||
import { Batcher } from './export/Batcher'; | ||
import { Metric } from './Metric'; | ||
|
||
/** This is a SDK implementation of UpDownCounter Metric. */ | ||
export class UpDownCounterMetric extends Metric<BoundUpDownCounter> | ||
implements api.UpDownCounter { | ||
constructor( | ||
name: string, | ||
options: MetricOptions, | ||
private readonly _batcher: Batcher, | ||
resource: Resource | ||
) { | ||
super(name, options, MetricKind.UP_DOWN_COUNTER, resource); | ||
} | ||
protected _makeInstrument(labels: api.Labels): BoundUpDownCounter { | ||
return new BoundUpDownCounter( | ||
labels, | ||
this._disabled, | ||
this._valueType, | ||
this._logger, | ||
this._batcher.aggregatorFor(this._descriptor) | ||
); | ||
} | ||
|
||
/** | ||
* Adds the given value to the current value. Values cannot be negative. | ||
* @param value the value to add. | ||
* @param [labels = {}] key-values pairs that are associated with a specific | ||
* metric that you want to record. | ||
*/ | ||
add(value: number, labels: api.Labels = {}) { | ||
this.bind(labels).add(value); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters