-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Expose TemporalitySelector funcs #7346
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package metric // import "go.opentelemetry.io/otel/sdk/metric" | ||
|
||
import "strings" | ||
|
||
// TemporalityPreference defines the user's desired temporality for metrics instruments. | ||
type TemporalityPreference string | ||
|
||
const ( | ||
// TemporalityPreferenceDefault indicates the SDK's default temporality should be used. | ||
TemporalityPreferenceDefault TemporalityPreference = "" | ||
|
||
// TemporalityPreferenceCumulative indicates a cumulative temporality should be used. | ||
TemporalityPreferenceCumulative TemporalityPreference = "cumulative" | ||
|
||
// TemporalityPreferenceDelta indicates a delta temporality should be used. | ||
TemporalityPreferenceDelta TemporalityPreference = "delta" | ||
|
||
// TemporalityPreferenceLowMemory indicates temporality preference that optimizes memory use. | ||
TemporalityPreferenceLowMemory TemporalityPreference = "lowmemory" | ||
) | ||
|
||
// IsValid returns true whether the preference is a valid string constant. | ||
func (t TemporalityPreference) IsValid() bool { | ||
switch t.lowercase() { | ||
case TemporalityPreferenceCumulative, | ||
TemporalityPreferenceDelta, | ||
TemporalityPreferenceLowMemory, | ||
TemporalityPreferenceDefault: | ||
return true | ||
default: | ||
return false | ||
} | ||
} | ||
|
||
func (t TemporalityPreference) lowercase() TemporalityPreference { | ||
return TemporalityPreference(strings.ToLower(string(t))) | ||
} | ||
|
||
// TemporalitySelectorForPreference will return a TemporalitySelector for the given preference. | ||
func TemporalitySelectorForPreference(t TemporalityPreference) TemporalitySelector { | ||
switch t.lowercase() { | ||
case TemporalityPreferenceCumulative: | ||
return CumulativeTemporalitySelector | ||
case TemporalityPreferenceDelta: | ||
return DeltaTemporalitySelector | ||
case TemporalityPreferenceLowMemory: | ||
return LowMemoryTemporalitySelector | ||
default: | ||
return DefaultTemporalitySelector | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These should not be added to the SDK. They duplicate existing configuration.