-
Notifications
You must be signed in to change notification settings - Fork 961
Add support to finish instrument recording #7792
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
base: main
Are you sure you want to change the base?
Changes from all commits
46b8bc1
abed63f
eff27c4
4f2eda7
061cde5
41fcb39
2a82801
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -45,4 +45,23 @@ public interface DoubleCounter { | |
| * @param context The explicit context to associate with this measurement. | ||
| */ | ||
| void add(double value, Attributes attributes, Context context); | ||
|
|
||
| /** | ||
| * Finish the instrument record. | ||
| * | ||
| * @param attributes A set of attributes to identify the instrument. | ||
| * @since 1.56.0 | ||
| */ | ||
| default void finish(Attributes attributes) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This really needs to be |
||
| finish(attributes, Context.current()); | ||
| } | ||
|
|
||
| /** | ||
| * Finish the instrument record. | ||
| * | ||
| * @param attributes A set of attributes to identify the instrument. | ||
| * @param context The explicit context to associate with this measurement. | ||
| * @since 1.56.0 | ||
| */ | ||
| default void finish(Attributes attributes, Context context) {} | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since there is no SDK functionality that depends on context, we don't need it as an argument. |
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,33 @@ | ||
| Comparing source compatibility of opentelemetry-api-1.61.0-SNAPSHOT.jar against opentelemetry-api-1.60.1.jar | ||
| No changes. | ||
| *** MODIFIED INTERFACE: PUBLIC ABSTRACT io.opentelemetry.api.metrics.DoubleCounter (not serializable) | ||
| === CLASS FILE FORMAT VERSION: 52.0 <- 52.0 | ||
| +++ NEW METHOD: PUBLIC(+) void finish(io.opentelemetry.api.common.Attributes) | ||
| +++ NEW METHOD: PUBLIC(+) void finish(io.opentelemetry.api.common.Attributes, io.opentelemetry.context.Context) | ||
| *** MODIFIED INTERFACE: PUBLIC ABSTRACT io.opentelemetry.api.metrics.DoubleGauge (not serializable) | ||
| === CLASS FILE FORMAT VERSION: 52.0 <- 52.0 | ||
| +++ NEW METHOD: PUBLIC(+) void finish(io.opentelemetry.api.common.Attributes) | ||
| +++ NEW METHOD: PUBLIC(+) void finish(io.opentelemetry.api.common.Attributes, io.opentelemetry.context.Context) | ||
| *** MODIFIED INTERFACE: PUBLIC ABSTRACT io.opentelemetry.api.metrics.DoubleHistogram (not serializable) | ||
| === CLASS FILE FORMAT VERSION: 52.0 <- 52.0 | ||
| +++ NEW METHOD: PUBLIC(+) void finish(io.opentelemetry.api.common.Attributes) | ||
| +++ NEW METHOD: PUBLIC(+) void finish(io.opentelemetry.api.common.Attributes, io.opentelemetry.context.Context) | ||
| *** MODIFIED INTERFACE: PUBLIC ABSTRACT io.opentelemetry.api.metrics.DoubleUpDownCounter (not serializable) | ||
| === CLASS FILE FORMAT VERSION: 52.0 <- 52.0 | ||
| +++ NEW METHOD: PUBLIC(+) void finish(io.opentelemetry.api.common.Attributes) | ||
| +++ NEW METHOD: PUBLIC(+) void finish(io.opentelemetry.api.common.Attributes, io.opentelemetry.context.Context) | ||
| *** MODIFIED INTERFACE: PUBLIC ABSTRACT io.opentelemetry.api.metrics.LongCounter (not serializable) | ||
| === CLASS FILE FORMAT VERSION: 52.0 <- 52.0 | ||
| +++ NEW METHOD: PUBLIC(+) void finish(io.opentelemetry.api.common.Attributes) | ||
| +++ NEW METHOD: PUBLIC(+) void finish(io.opentelemetry.api.common.Attributes, io.opentelemetry.context.Context) | ||
| *** MODIFIED INTERFACE: PUBLIC ABSTRACT io.opentelemetry.api.metrics.LongGauge (not serializable) | ||
| === CLASS FILE FORMAT VERSION: 52.0 <- 52.0 | ||
| +++ NEW METHOD: PUBLIC(+) void finish(io.opentelemetry.api.common.Attributes) | ||
| +++ NEW METHOD: PUBLIC(+) void finish(io.opentelemetry.api.common.Attributes, io.opentelemetry.context.Context) | ||
| *** MODIFIED INTERFACE: PUBLIC ABSTRACT io.opentelemetry.api.metrics.LongHistogram (not serializable) | ||
| === CLASS FILE FORMAT VERSION: 52.0 <- 52.0 | ||
| +++ NEW METHOD: PUBLIC(+) void finish(io.opentelemetry.api.common.Attributes) | ||
| +++ NEW METHOD: PUBLIC(+) void finish(io.opentelemetry.api.common.Attributes, io.opentelemetry.context.Context) | ||
| *** MODIFIED INTERFACE: PUBLIC ABSTRACT io.opentelemetry.api.metrics.LongUpDownCounter (not serializable) | ||
| === CLASS FILE FORMAT VERSION: 52.0 <- 52.0 | ||
| +++ NEW METHOD: PUBLIC(+) void finish(io.opentelemetry.api.common.Attributes) | ||
| +++ NEW METHOD: PUBLIC(+) void finish(io.opentelemetry.api.common.Attributes, io.opentelemetry.context.Context) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -224,6 +224,19 @@ void doRecordDouble(double value, Attributes attributes, Context context) { | |
| } | ||
| } | ||
|
|
||
| @Override | ||
| public void remove(Attributes attributes, Context context) { | ||
| if (!enabled) { | ||
| return; | ||
| } | ||
| AggregatorHolder<T> holderForRecord = getHolderForRecord(); | ||
| try { | ||
| holderForRecord.aggregatorHandles.remove(attributes); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As @dashpole points out, this is too naive as it removes series without a final report of their data. |
||
| } finally { | ||
| releaseHolderForRecord(holderForRecord); | ||
| } | ||
| } | ||
|
|
||
| @Nullable | ||
| @Override | ||
| AggregatorHandle<T> maybeGetPooledAggregatorHandle() { | ||
|
|
@@ -421,6 +434,14 @@ void doRecordDouble(double value, Attributes attributes, Context context) { | |
| .recordDouble(value, attributes, context); | ||
| } | ||
|
|
||
| @Override | ||
| public void remove(Attributes attributes, Context context) { | ||
| if (!enabled) { | ||
| return; | ||
| } | ||
| aggregatorHandles.remove(attributes); | ||
| } | ||
|
|
||
| @Nullable | ||
| @Override | ||
| AggregatorHandle<T> maybeGetPooledAggregatorHandle() { | ||
|
|
||
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.
#nit: we manaully add since annotations as part of the release process. This ensures that they accurately reflect the version changes were first published in. So just omit the annotation here.