Skip to content
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

Add temporality option to readers #2944

Closed
MrAlias opened this issue Jun 6, 2022 · 5 comments
Closed

Add temporality option to readers #2944

MrAlias opened this issue Jun 6, 2022 · 5 comments
Assignees
Labels
area:metrics Part of OpenTelemetry Metrics pkg:SDK Related to an SDK package

Comments

@MrAlias
Copy link
Contributor

MrAlias commented Jun 6, 2022

Measurement temporality is defined at the reader level in the specification:

To construct a MetricReader when setting up an SDK, the caller SHOULD provide at least the following:
[...]

  • The default output temporality (optional), a function of instrument kind. If not configured, the Cumulative temporality SHOULD be used.

The manual and periodic readers need to accept an option to configure this.

@MrAlias MrAlias added pkg:SDK Related to an SDK package area:metrics Part of OpenTelemetry Metrics labels Jun 6, 2022
@MrAlias MrAlias added this to the Metric SDK: Alpha milestone Jun 6, 2022
@MrAlias MrAlias assigned MrAlias and unassigned MrAlias Jun 6, 2022
@MrAlias
Copy link
Contributor Author

MrAlias commented Jun 6, 2022

Possible implementation:

package metric

// Temporality is a measurement intervals relationship to time.
type Temporality uint8

const (
	// CumulativeTemporality defines a measurement interval that continues to
	// expand forward in time from a starting point. New measurements are
	// added to all previous measurements since a start time.
	CumulativeTemporality Temporality = iota

	// DeltaTemporality defines a measurement interval that resets each cycle.
	// Measurements from one cycle are recorded independently, measurements
	// from other cycles do not affect them.
	DeltaTemporality
)

// WithTemporality uses the selector to determine the Temporality measurements
// from instrument should be recorded with.
func WithTemporality(selector func(instrument view.Instrument) Temporality) PeriodicReaderOption {
	/* ... */
}

// Add a similar option for a manual reader.

@MrAlias
Copy link
Contributor Author

MrAlias commented Jun 6, 2022

Blocked on the view.Instrument or equivalent type being added.

@MadVikingGod
Copy link
Contributor

I think there will also need to be a way for the Meter to request this information from a reader, so it can use it when creating the instrument. So we should probably expose something like this in the Reader interface.

@Aneurysm9
Copy link
Member

We should be careful how we define constants to represent these options and consider keeping them in line with the OTLP definitions, which would be:

const (
  undefinedTemporality Temporality = iota
  DeltaTemporality
  CumulativeTemporality
)

We would probably want to leave undefinedTemporality unexported as it should never be explicitly provided.

@MrAlias
Copy link
Contributor Author

MrAlias commented Jun 16, 2022

Closed #2949

@MrAlias MrAlias closed this as completed Jun 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:metrics Part of OpenTelemetry Metrics pkg:SDK Related to an SDK package
Projects
No open projects
Development

No branches or pull requests

3 participants