-
Notifications
You must be signed in to change notification settings - Fork 850
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into array-span-attributes
- Loading branch information
Showing
23 changed files
with
302 additions
and
83 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
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
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
60 changes: 60 additions & 0 deletions
60
sdk/src/main/java/io/opentelemetry/sdk/metrics/Aggregator.java
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,60 @@ | ||
/* | ||
* Copyright 2020, 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 | ||
* | ||
* http://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. | ||
*/ | ||
|
||
package io.opentelemetry.sdk.metrics; | ||
|
||
import javax.annotation.concurrent.ThreadSafe; | ||
|
||
/** Aggregator represents the base class for all the available aggregations. */ | ||
@ThreadSafe | ||
interface Aggregator<T extends Aggregator<?>> { | ||
|
||
/** | ||
* Merge aggregated values between the current instance and the given {@code aggregator}. | ||
* | ||
* @param aggregator value to merge with. | ||
*/ | ||
void merge(T aggregator); | ||
|
||
/** | ||
* LongAggregator represents the base class for all the available aggregations that work with long | ||
* values. | ||
*/ | ||
@ThreadSafe | ||
interface LongAggregator<T extends LongAggregator<?>> extends Aggregator<T> { | ||
|
||
/** | ||
* Updates the current aggregator with a newly recorded value. | ||
* | ||
* @param value the new {@code long} value to be added. | ||
*/ | ||
void update(long value); | ||
} | ||
|
||
/** | ||
* DoubleAggregator represents the base class for all the available aggregations that work with | ||
* double values. | ||
*/ | ||
@ThreadSafe | ||
interface DoubleAggregator<T extends DoubleAggregator<?>> extends Aggregator<T> { | ||
/** | ||
* Updates the current aggregator with a newly recorded value. | ||
* | ||
* @param value the new {@code double} value to be added. | ||
*/ | ||
void update(double 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
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
38 changes: 38 additions & 0 deletions
38
sdk/src/main/java/io/opentelemetry/sdk/metrics/DoubleSumAggregator.java
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,38 @@ | ||
/* | ||
* Copyright 2020, 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 | ||
* | ||
* http://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. | ||
*/ | ||
|
||
package io.opentelemetry.sdk.metrics; | ||
|
||
import com.google.common.util.concurrent.AtomicDouble; | ||
|
||
final class DoubleSumAggregator implements Aggregator.DoubleAggregator<DoubleSumAggregator> { | ||
// TODO: Change to use DoubleAdder when changed to java8. | ||
private final AtomicDouble value; | ||
|
||
DoubleSumAggregator() { | ||
this.value = new AtomicDouble(); | ||
} | ||
|
||
@Override | ||
public void merge(DoubleSumAggregator other) { | ||
this.value.addAndGet(other.value.get()); | ||
} | ||
|
||
@Override | ||
public void update(double value) { | ||
this.value.addAndGet(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
Oops, something went wrong.