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

Attribute sets not observed during async callbacks are not exported #3242

Merged
merged 4 commits into from
Aug 10, 2023

Conversation

dashpole
Copy link
Contributor

@dashpole dashpole commented Feb 21, 2023

Part of #2711

Non-Goals

This is limited to asynchronous instruments in order to minimize the changes required for SDKs. It could be extended to synchronous instruments in the future with a Delete() function, as requested in #3062. Implementing this specification would allow temporarily working around the limitation for synchronous instruments in some cases as described in #3062 (comment), and would validate the approach recommended here before making the addition to the API.

This does not impose additional requirements on the SDK's handling of start time.

Changes

This updates the metric SDK specification to recommend against producing aggregated metric data for attribute sets which are not observed during a callback. This helps the use-cases below by allowing the SDK to free memory for non-observed attribute sets, and allows for the intentional removal of series by omitting them from the callback.

It also adds to the supplementary guidelines to describe how to handle start time for attribute sets which disappear and reappear if the SDK tracks per-timeseries start time.

Use-cases

Memory management: As described in open-telemetry/opentelemetry-go#3605 (comment), and #1891, infinite cardinality recordings can cause memory problems if all previously observed attribute sets are kept in-memory, and continue to be exported. If SDKs are not expected to produce aggregated data for non-observed attribute sets, they are able to limit memory to only what is required by actively-reported attribute sets when using async instruments.

Intentional Removal of Series: As described in #3062 (comment), a user may want a particular series to cease being reported to their backend.

Related Issues:

cc @asafm @MrAlias @jkwatson @jack-berg @reyang @jmacd

@arminru arminru added spec:metrics Related to the specification/metrics directory area:sdk Related to the SDK labels Feb 28, 2023
@dashpole
Copy link
Contributor Author

I'm out on leave for a while. Others can feel free to contribute the changes, or i'll pick it back up when I'm back.

@dashpole
Copy link
Contributor Author

I'm back from leave, and would like to pick this back up. Reviews are appreciated

@asafm
Copy link
Contributor

asafm commented Jul 2, 2023

@dashpole The change described in this PR is what the Java SDK is doing today. So this PR makes this explicit? I thought that all SDKs "forgot" the previously recorded points.

@dashpole
Copy link
Contributor Author

dashpole commented Jul 2, 2023

So this PR makes this explicit?

Yes

I thought that all SDKs "forgot" the previously recorded points.

Golang does not (see open-telemetry/opentelemetry-go#3605, and the original comment thread, open-telemetry/opentelemetry-go#3549 (review)). Part of the rationale was that the spec was silent on whether non-observed attribute sets should be exported, which this PR attempts to clarify. I can look through other SDKs to see what other SDKs do.

@github-actions
Copy link

This PR was marked stale due to lack of activity. It will be closed in 7 days.

@github-actions github-actions bot added the Stale label Jul 10, 2023
@MrAlias MrAlias removed the Stale label Jul 10, 2023
@github-actions
Copy link

This PR was marked stale due to lack of activity. It will be closed in 7 days.

@github-actions github-actions bot added the Stale label Jul 26, 2023
@MrAlias MrAlias removed the Stale label Jul 26, 2023
@github-actions
Copy link

github-actions bot commented Aug 9, 2023

This PR was marked stale due to lack of activity. It will be closed in 7 days.

@github-actions github-actions bot added the Stale label Aug 9, 2023
@MrAlias
Copy link
Contributor

MrAlias commented Aug 9, 2023

@carlosalberto should this also be included in the upcoming release?

I think this is a non-controversial change that is just explicitly stating what is already being done. It should be ready to merge right?

@MrAlias MrAlias removed the Stale label Aug 9, 2023
@trask
Copy link
Member

trask commented Aug 9, 2023

just checking, is this PR still needed now with the new clarification being added in #3540?

For asynchronous instruments with Delta or Cumulative aggregation temporality, MetricReader.Collect MUST only receive data points with measurements recorded since the previous collection.

@dashpole
Copy link
Contributor Author

dashpole commented Aug 9, 2023

The updates to the supplementary guidelines are still helpful. The language in sdk.md isn't needed after that change.

@reyang
Copy link
Member

reyang commented Aug 10, 2023

@dashpole would you move the changelog entry to unreleased?

@dashpole
Copy link
Contributor Author

@reyang updated the changelog

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:sdk Related to the SDK spec:metrics Related to the specification/metrics directory
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants