Skip to content

Commit

Permalink
Set IsMonotonic to true for opencensus sum (#3389)
Browse files Browse the repository at this point in the history
* Set IsMonotonic to true for opencensus sum 

fix #3388

* Update metric_test.go

* fix test

* add changelog

* Update CHANGELOG.md

Co-authored-by: Tyler Yahn <[email protected]>

Co-authored-by: Tyler Yahn <[email protected]>
  • Loading branch information
ktong and MrAlias authored Oct 27, 2022
1 parent 667a201 commit 94ae231
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
### Fixed

- The `go.opentelemetry.io/otel/exporters/prometheus` exporter fixes duplicated `_total` suffixes. (#3369)
- Cumulative metrics from the OpenCensus bridge (`go.opentelemetry.io/otel/bridge/opencensus`) are defined as monotonic sums, instead of non-monotonic. (#3389)
- Asynchronous counters (`Counter` and `UpDownCounter`) from the metric SDK now produce delta sums when configured with delta temporality. (#3398)

## [1.11.1/0.33.0] 2022-10-19
Expand Down
2 changes: 1 addition & 1 deletion bridge/opencensus/internal/ocmetric/metric.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func convertGauge[N int64 | float64](labelKeys []ocmetricdata.LabelKey, ts []*oc
func convertSum[N int64 | float64](labelKeys []ocmetricdata.LabelKey, ts []*ocmetricdata.TimeSeries) (metricdata.Sum[N], error) {
points, err := convertNumberDataPoints[N](labelKeys, ts)
// OpenCensus sums are always Cumulative
return metricdata.Sum[N]{DataPoints: points, Temporality: metricdata.CumulativeTemporality}, err
return metricdata.Sum[N]{DataPoints: points, Temporality: metricdata.CumulativeTemporality, IsMonotonic: true}, err
}

// convertNumberDataPoints converts OpenCensus TimeSeries to OpenTelemetry DataPoints.
Expand Down
3 changes: 3 additions & 0 deletions bridge/opencensus/internal/ocmetric/metric_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,7 @@ func TestConvertMetrics(t *testing.T) {
Description: "an int testing sum",
Unit: unit.Milliseconds,
Data: metricdata.Sum[int64]{
IsMonotonic: true,
Temporality: metricdata.CumulativeTemporality,
DataPoints: []metricdata.DataPoint[int64]{
{
Expand Down Expand Up @@ -342,6 +343,7 @@ func TestConvertMetrics(t *testing.T) {
Description: "a float testing sum",
Unit: unit.Milliseconds,
Data: metricdata.Sum[float64]{
IsMonotonic: true,
Temporality: metricdata.CumulativeTemporality,
DataPoints: []metricdata.DataPoint[float64]{
{
Expand Down Expand Up @@ -410,6 +412,7 @@ func TestConvertMetrics(t *testing.T) {
Description: "a testing sum",
Unit: unit.Dimensionless,
Data: metricdata.Sum[float64]{
IsMonotonic: true,
Temporality: metricdata.CumulativeTemporality,
DataPoints: []metricdata.DataPoint[float64]{},
},
Expand Down

0 comments on commit 94ae231

Please sign in to comment.