Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import io.opentelemetry.api.common.Attributes;
import io.opentelemetry.context.Context;
import java.util.function.Predicate;
import javax.annotation.concurrent.ThreadSafe;

/**
Expand Down Expand Up @@ -60,4 +61,23 @@ default boolean isEnabled() {
* @param context The explicit context to associate with this measurement.
*/
void add(double value, Attributes attributes, Context context);

/**
* Finish the recording of the instrument.
*
* @param condition A function evaluating which instruments to remove based on their attributes.
Comment on lines +66 to +68
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

from reading through the spec issue, this isn't remove an instrument, correct? It's potentially removing a timeseries identified by the attributes? Is that correct? As a potential end-user, I find this to be a super confusing API. It's very unclear when I would want to use this, and what the impact of the predicate implementation might need to be. Before I'd want to add this officially to the APIs, I'd want the javadoc here to be greatly expanded with examples and clarifications about what this API would be used for.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Worth discussing at SIG.

* @since TODO
*/
default void finish(Predicate<Attributes> condition) {
finish(condition, Context.current());
}

/**
* Finish the recording of the instrument.
*
* @param condition A function evaluating which instruments to remove based on their attributes.
* @param context The explicit context to associate with this measurement.
* @since TODO
*/
default void finish(Predicate<Attributes> condition, Context context) {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import io.opentelemetry.api.common.Attributes;
import io.opentelemetry.context.Context;
import java.util.function.Predicate;
import javax.annotation.concurrent.ThreadSafe;

/**
Expand Down Expand Up @@ -54,4 +55,23 @@ default boolean isEnabled() {
* @param context The explicit context to associate with this measurement.
*/
void set(double value, Attributes attributes, Context context);

/**
* Finish the recording of the instrument.
*
* @param condition A function evaluating which instruments to remove based on their attributes.
* @since TODO
*/
default void finish(Predicate<Attributes> condition) {
finish(condition, Context.current());
}

/**
* Finish the recording of the instrument.
*
* @param condition A function evaluating which instruments to remove based on their attributes.
* @param context The explicit context to associate with this measurement.
* @since TODO
*/
default void finish(Predicate<Attributes> condition, Context context) {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import io.opentelemetry.api.common.Attributes;
import io.opentelemetry.context.Context;
import java.util.function.Predicate;
import javax.annotation.concurrent.ThreadSafe;

/**
Expand Down Expand Up @@ -60,4 +61,23 @@ default boolean isEnabled() {
* @param context The explicit context to associate with this measurement.
*/
void record(double value, Attributes attributes, Context context);

/**
* Finish the recording of the instrument.
*
* @param condition A function evaluating which instruments to remove based on their attributes.
* @since TODO
*/
default void finish(Predicate<Attributes> condition) {
finish(condition, Context.current());
}

/**
* Finish the recording of the instrument.
*
* @param condition A function evaluating which instruments to remove based on their attributes.
* @param context The explicit context to associate with this measurement.
* @since TODO
*/
default void finish(Predicate<Attributes> condition, Context context) {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import io.opentelemetry.api.common.Attributes;
import io.opentelemetry.context.Context;
import java.util.function.Predicate;
import javax.annotation.concurrent.ThreadSafe;

/**
Expand Down Expand Up @@ -60,4 +61,23 @@ default boolean isEnabled() {
* @param context The explicit context to associate with this measurement.
*/
void add(double value, Attributes attributes, Context context);

/**
* Finish the recording of the instrument.
*
* @param condition A function evaluating which instruments to remove based on their attributes.
* @since TODO
*/
default void finish(Predicate<Attributes> condition) {
finish(condition, Context.current());
}

/**
* Finish the recording of the instrument.
*
* @param condition A function evaluating which instruments to remove based on their attributes.
* @param context The explicit context to associate with this measurement.
* @since TODO
*/
default void finish(Predicate<Attributes> condition, Context context) {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import io.opentelemetry.api.common.Attributes;
import io.opentelemetry.context.Context;
import java.util.function.Predicate;
import javax.annotation.concurrent.ThreadSafe;

/**
Expand Down Expand Up @@ -60,4 +61,23 @@ default boolean isEnabled() {
* @param context The explicit context to associate with this measurement.
*/
void add(long value, Attributes attributes, Context context);

/**
* Finish the recording of the instrument.
*
* @param condition A function evaluating which instruments to remove based on their attributes.
* @since TODO
*/
default void finish(Predicate<Attributes> condition) {
finish(condition, Context.current());
}

/**
* Finish the recording of the instrument.
*
* @param condition A function evaluating which instruments to remove based on their attributes.
* @param context The explicit context to associate with this measurement.
* @since TODO
*/
default void finish(Predicate<Attributes> condition, Context context) {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import io.opentelemetry.api.common.Attributes;
import io.opentelemetry.context.Context;
import java.util.function.Predicate;
import javax.annotation.concurrent.ThreadSafe;

/**
Expand Down Expand Up @@ -54,4 +55,23 @@ default boolean isEnabled() {
* @param context The explicit context to associate with this measurement.
*/
void set(long value, Attributes attributes, Context context);

/**
* Finish the recording of the instrument.
*
* @param condition A function evaluating which instruments to remove based on their attributes.
* @since TODO
*/
default void finish(Predicate<Attributes> condition) {
finish(condition, Context.current());
}

/**
* Finish the recording of the instrument.
*
* @param condition A function evaluating which instruments to remove based on their attributes.
* @param context The explicit context to associate with this measurement.
* @since TODO
*/
default void finish(Predicate<Attributes> condition, Context context) {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import io.opentelemetry.api.common.Attributes;
import io.opentelemetry.context.Context;
import java.util.function.Predicate;
import javax.annotation.concurrent.ThreadSafe;

/**
Expand Down Expand Up @@ -60,4 +61,23 @@ default boolean isEnabled() {
* @param context The explicit context to associate with this measurement.
*/
void record(long value, Attributes attributes, Context context);

/**
* Finish the recording of the instrument.
*
* @param condition A function evaluating which instruments to remove based on their attributes.
* @since TODO
*/
default void finish(Predicate<Attributes> condition) {
finish(condition, Context.current());
}

/**
* Finish the recording of the instrument.
*
* @param condition A function evaluating which instruments to remove based on their attributes.
* @param context The explicit context to associate with this measurement.
* @since TODO
*/
default void finish(Predicate<Attributes> condition, Context context) {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import io.opentelemetry.api.common.Attributes;
import io.opentelemetry.context.Context;
import java.util.function.Predicate;
import javax.annotation.concurrent.ThreadSafe;

/**
Expand Down Expand Up @@ -60,4 +61,23 @@ default boolean isEnabled() {
* @param context The explicit context to associate with this measurement.
*/
void add(long value, Attributes attributes, Context context);

/**
* Finish the recording of the instrument.
*
* @param condition A function evaluating which instruments to remove based on their attributes.
* @since TODO
*/
default void finish(Predicate<Attributes> condition) {
finish(condition, Context.current());
}

/**
* Finish the recording of the instrument.
*
* @param condition A function evaluating which instruments to remove based on their attributes.
* @param context The explicit context to associate with this measurement.
* @since TODO
*/
default void finish(Predicate<Attributes> condition, Context context) {}
}
33 changes: 32 additions & 1 deletion docs/apidiffs/current_vs_latest/opentelemetry-api.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,33 @@
Comparing source compatibility of opentelemetry-api-1.62.0-SNAPSHOT.jar against opentelemetry-api-1.61.0.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(java.util.function.Function<io.opentelemetry.api.common.Attributes,java.lang.Boolean>)
+++ NEW METHOD: PUBLIC(+) void finish(java.util.function.Function<io.opentelemetry.api.common.Attributes,java.lang.Boolean>, 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(java.util.function.Function<io.opentelemetry.api.common.Attributes,java.lang.Boolean>)
+++ NEW METHOD: PUBLIC(+) void finish(java.util.function.Function<io.opentelemetry.api.common.Attributes,java.lang.Boolean>, 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(java.util.function.Function<io.opentelemetry.api.common.Attributes,java.lang.Boolean>)
+++ NEW METHOD: PUBLIC(+) void finish(java.util.function.Function<io.opentelemetry.api.common.Attributes,java.lang.Boolean>, 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(java.util.function.Function<io.opentelemetry.api.common.Attributes,java.lang.Boolean>)
+++ NEW METHOD: PUBLIC(+) void finish(java.util.function.Function<io.opentelemetry.api.common.Attributes,java.lang.Boolean>, 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(java.util.function.Function<io.opentelemetry.api.common.Attributes,java.lang.Boolean>)
+++ NEW METHOD: PUBLIC(+) void finish(java.util.function.Function<io.opentelemetry.api.common.Attributes,java.lang.Boolean>, 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(java.util.function.Function<io.opentelemetry.api.common.Attributes,java.lang.Boolean>)
+++ NEW METHOD: PUBLIC(+) void finish(java.util.function.Function<io.opentelemetry.api.common.Attributes,java.lang.Boolean>, 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(java.util.function.Function<io.opentelemetry.api.common.Attributes,java.lang.Boolean>)
+++ NEW METHOD: PUBLIC(+) void finish(java.util.function.Function<io.opentelemetry.api.common.Attributes,java.lang.Boolean>, 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(java.util.function.Function<io.opentelemetry.api.common.Attributes,java.lang.Boolean>)
+++ NEW METHOD: PUBLIC(+) void finish(java.util.function.Function<io.opentelemetry.api.common.Attributes,java.lang.Boolean>, io.opentelemetry.context.Context)
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import io.opentelemetry.sdk.metrics.internal.descriptor.InstrumentDescriptor;
import io.opentelemetry.sdk.metrics.internal.state.WriteableMetricStorage;
import java.util.function.Consumer;
import java.util.function.Predicate;
import java.util.logging.Level;
import java.util.logging.Logger;

Expand Down Expand Up @@ -61,6 +62,11 @@ public void add(double increment) {
add(increment, Attributes.empty());
}

@Override
public void finish(Predicate<Attributes> condition, Context context) {
storage.finish(condition, context);
}

static class SdkDoubleCounterBuilder implements DoubleCounterBuilder {

final InstrumentBuilder builder;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import io.opentelemetry.sdk.metrics.internal.descriptor.InstrumentDescriptor;
import io.opentelemetry.sdk.metrics.internal.state.WriteableMetricStorage;
import java.util.function.Consumer;
import java.util.function.Predicate;

class SdkDoubleGauge extends AbstractInstrument implements DoubleGauge {

Expand Down Expand Up @@ -48,6 +49,11 @@ public void set(double value) {
set(value, Attributes.empty());
}

@Override
public void finish(Predicate<Attributes> condition, Context context) {
storage.finish(condition, context);
}

static class SdkDoubleGaugeBuilder implements DoubleGaugeBuilder {
final InstrumentBuilder builder;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import io.opentelemetry.sdk.metrics.internal.state.WriteableMetricStorage;
import java.util.List;
import java.util.Objects;
import java.util.function.Predicate;
import java.util.logging.Level;
import java.util.logging.Logger;

Expand Down Expand Up @@ -61,6 +62,11 @@ public void record(double value) {
record(value, Attributes.empty());
}

@Override
public void finish(Predicate<Attributes> condition, Context context) {
storage.finish(condition, context);
}

static class SdkDoubleHistogramBuilder implements DoubleHistogramBuilder {

final InstrumentBuilder builder;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import io.opentelemetry.sdk.metrics.internal.descriptor.InstrumentDescriptor;
import io.opentelemetry.sdk.metrics.internal.state.WriteableMetricStorage;
import java.util.function.Consumer;
import java.util.function.Predicate;

class SdkDoubleUpDownCounter extends AbstractInstrument implements DoubleUpDownCounter {

Expand Down Expand Up @@ -48,6 +49,11 @@ public void add(double increment) {
add(increment, Attributes.empty());
}

@Override
public void finish(Predicate<Attributes> condition, Context context) {
storage.finish(condition, context);
}

static class SdkDoubleUpDownCounterBuilder implements DoubleUpDownCounterBuilder {

final InstrumentBuilder builder;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import io.opentelemetry.sdk.metrics.internal.descriptor.InstrumentDescriptor;
import io.opentelemetry.sdk.metrics.internal.state.WriteableMetricStorage;
import java.util.function.Consumer;
import java.util.function.Predicate;
import java.util.logging.Level;
import java.util.logging.Logger;

Expand Down Expand Up @@ -62,6 +63,11 @@ public void add(long increment) {
add(increment, Attributes.empty());
}

@Override
public void finish(Predicate<Attributes> condition, Context context) {
storage.finish(condition, context);
}

static class SdkLongCounterBuilder implements LongCounterBuilder {

final InstrumentBuilder builder;
Expand Down
Loading
Loading