forked from open-telemetry/opentelemetry-go
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "Cleanup interaction of exemplar and aggregation (open-telemet…
- Loading branch information
Showing
16 changed files
with
169 additions
and
165 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package aggregate // import "go.opentelemetry.io/otel/sdk/metric/internal/aggregate" | ||
|
||
import ( | ||
"context" | ||
|
||
"go.opentelemetry.io/otel/attribute" | ||
"go.opentelemetry.io/otel/sdk/metric/exemplar" | ||
) | ||
|
||
// dropReservoir returns a [FilteredReservoir] that drops all measurements it is offered. | ||
func dropReservoir[N int64 | float64](attribute.Set) FilteredExemplarReservoir[N] { | ||
return &dropRes[N]{} | ||
} | ||
|
||
type dropRes[N int64 | float64] struct{} | ||
|
||
// Offer does nothing, all measurements offered will be dropped. | ||
func (r *dropRes[N]) Offer(context.Context, N, []attribute.KeyValue) {} | ||
|
||
// Collect resets dest. No exemplars will ever be returned. | ||
func (r *dropRes[N]) Collect(dest *[]exemplar.Exemplar) { | ||
*dest = (*dest)[:0] | ||
} |
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,27 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package aggregate | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
|
||
"go.opentelemetry.io/otel/attribute" | ||
"go.opentelemetry.io/otel/sdk/metric/exemplar" | ||
) | ||
|
||
func TestDrop(t *testing.T) { | ||
t.Run("Int64", testDropFiltered[int64]) | ||
t.Run("Float64", testDropFiltered[float64]) | ||
} | ||
|
||
func testDropFiltered[N int64 | float64](t *testing.T) { | ||
r := dropReservoir[N](*attribute.EmptySet()) | ||
|
||
var dest []exemplar.Exemplar | ||
r.Collect(&dest) | ||
|
||
assert.Empty(t, dest, "non-sampled context should not be offered") | ||
} |
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
Oops, something went wrong.