Skip to content
This repository has been archived by the owner on Dec 6, 2024. It is now read-only.

Metric Observer instrument specification (refinement) #72

Merged
merged 10 commits into from
Jan 8, 2020

Conversation

jmacd
Copy link
Contributor

@jmacd jmacd commented Dec 6, 2019

This is a clarification of the format OTEP 0008. This topic encountered last-minute debate in open-telemetry/opentelemetry-specification#250 and was left out. The section on calling conventions and examples here should clarify the issue.

Copy link
Member

@yurishkuro yurishkuro left a comment

Choose a reason for hiding this comment

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

It seems that registering an observer does not require specifying any timing parameters, meaning that the timing of the callback invocations is fully controlled by the SDK. If that's the case, why is it necessary to introduce the new instrument type instead of just providing an ability to register anonymous callbacks invoked by the SDK according to its polling interval? Please add more color in the Motivation section.

text/0072-metric-observer.md Outdated Show resolved Hide resolved
text/0072-metric-observer.md Outdated Show resolved Hide resolved
@jmacd
Copy link
Contributor Author

jmacd commented Dec 9, 2019

@yurishkuro I've added two paragraphs to try to address your question. I will confess to having mixed feelings about this API. I volunteered to write this specification after I removed it from the metrics spec earlier, in an agreement with @bogdandrutu. My original draft in OTEP 0008 didn't talk much about about calling conventions, but I had not at that time been thinking of supporting "bound" observer instruments. The addition of bound observer instruments raises some questions (e.g., what prevents you from calling them in a different observer's callback?).

Another possibility (@bogdandrutu please comment) would be to support a callback for unbound observers and individual callbacks for each bound observer. Why support one callback per instrument, not one callback per bound instrument IOW?

@jmacd
Copy link
Contributor Author

jmacd commented Dec 9, 2019

(I've asked @bogdandrutu this in the past, and he expressed a preference for a single-callback as proposed here, not a callback per bound observer. It's fewer allocations.)

@jmacd jmacd added the metrics Relates to the Metrics API/SDK label Dec 12, 2019
@bogdandrutu
Copy link
Member

@jmacd it is not necessary about fewer allocation but also that a system (or external) call like (getting memory) may return data for more than one bound which means that if a callback per-bound is allocated the system call will be done multiple times. In case multiple system (or external) calls are required the callback can deal with that and update multiple bounds. As an example see https://github.com/open-telemetry/opentelemetry-java/blob/master/contrib/runtime_metrics/src/main/java/io/opentelemetry/contrib/metrics/runtime/GarbageCollector.java#L59 where I pre-allocate a list of bounds and update all of them after doing only one system/external call.

text/0072-metric-observer.md Show resolved Hide resolved
text/0072-metric-observer.md Outdated Show resolved Hide resolved
text/0072-metric-observer.md Outdated Show resolved Hide resolved
text/0072-metric-observer.md Outdated Show resolved Hide resolved
@jmacd
Copy link
Contributor Author

jmacd commented Dec 13, 2019

text/0072-metric-observer.md Outdated Show resolved Hide resolved
text/0072-metric-observer.md Outdated Show resolved Hide resolved
text/0072-metric-observer.md Outdated Show resolved Hide resolved
text/0072-metric-observer.md Outdated Show resolved Hide resolved
@jmacd
Copy link
Contributor Author

jmacd commented Jan 7, 2020

@bogdandrutu @c24t @yurishkuro please take another look.

convention is not needed for Observer instruments because there is
little if any performance benefit in doing so (as Observer instruments
are called during collection, there is no need to maintain "active"
records concurrent with collection).
Copy link
Member

Choose a reason for hiding this comment

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

Bounding an instrument may involve encoding the label set into a wire-ready data structure, which in itself can be expensive if it needs to be done repeatedly on every measurement.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The LabelSet value is meant to capture any encoding of label sets into wire-ready data structures, since these can be used for more than one bound instrument. In the example snippet, the label set is re-used to emphasize this. The only optimization that I can see would be if the Observer were to output more than once for the same LabelSet per collection period, in which case binding them would support the optimization.

private static final ObserverDouble cpuLoad = ...;

void init() {
LabelSet labelSet = meter.createLabelSet("low_power", isLowPowerMode());
Copy link
Member

Choose a reason for hiding this comment

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

compile error, missing final :-)

Copy link
Member

@yurishkuro yurishkuro left a comment

Choose a reason for hiding this comment

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

I think there may still be performance reason for a "bound observer", but it can be added later if needed, so lgtm.

@bogdandrutu bogdandrutu merged commit 048dbaf into open-telemetry:master Jan 8, 2020
@jmacd jmacd deleted the jmacd/otep_observer_gauge2 branch May 6, 2020 18:48
carlosalberto pushed a commit to carlosalberto/oteps that referenced this pull request Oct 23, 2024
)

* Update with calling conventions

* Typos

* Typos

* Formatting

* Add further motivation for Observer instruments, fix unbound variable in code samples

* Feedback for Bogdan's comments

* More depth re: c24t's feedback

* Remove bound instruments

* Show that the label set can be cached
carlosalberto pushed a commit to carlosalberto/oteps that referenced this pull request Oct 23, 2024
)

* Update with calling conventions

* Typos

* Typos

* Formatting

* Add further motivation for Observer instruments, fix unbound variable in code samples

* Feedback for Bogdan's comments

* More depth re: c24t's feedback

* Remove bound instruments

* Show that the label set can be cached
carlosalberto pushed a commit to carlosalberto/oteps that referenced this pull request Oct 30, 2024
)

* Update with calling conventions

* Typos

* Typos

* Formatting

* Add further motivation for Observer instruments, fix unbound variable in code samples

* Feedback for Bogdan's comments

* More depth re: c24t's feedback

* Remove bound instruments

* Show that the label set can be cached
carlosalberto pushed a commit to open-telemetry/opentelemetry-specification that referenced this pull request Nov 8, 2024
…/oteps#72)

* Update with calling conventions

* Typos

* Typos

* Formatting

* Add further motivation for Observer instruments, fix unbound variable in code samples

* Feedback for Bogdan's comments

* More depth re: c24t's feedback

* Remove bound instruments

* Show that the label set can be cached
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
metrics Relates to the Metrics API/SDK
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants