Opentelemetry-js: Consider how to deal with already registered metric

Created on 1 Nov 2019  路  2Comments  路  Source: open-telemetry/opentelemetry-js

Summary:

A given metric is only meant to be registered once, this issue is to decide how to handle duplicate or already registered metric (Currently not permitted and cause an error with Prometheus).

Possible Solutions:

  • Option 1: Replace the old registered metric by the new: This seems to be problematic, especially when you use the same name but different type or unit. This might create a problem in backend.

  • Option 2: Throw an error: This is not really advocated by the specs.

  • Option 3: Log a warning and skip duplicate metric: This might confuse the end users.

Suggest other options?

Agreed question

Most helpful comment

It is my opinion that Option 3 is the only currently viable option as option 1 may create problems with different backends (maybe this is handled by individual exporters?) and option 2 is not compatible with current spec (incorrect usage should not throw).

Option 3 may be confusing at first (generally I would expect it to behave like other Set-like APIs which overwrite rather than ignore if you try to set the same thing twice), but it is an easy to understand difference if documented properly.

All 2 comments

It is my opinion that Option 3 is the only currently viable option as option 1 may create problems with different backends (maybe this is handled by individual exporters?) and option 2 is not compatible with current spec (incorrect usage should not throw).

Option 3 may be confusing at first (generally I would expect it to behave like other Set-like APIs which overwrite rather than ignore if you try to set the same thing twice), but it is an easy to understand difference if documented properly.

Looks like we have an agreement here, closing this issue now.

Was this page helpful?
0 / 5 - 0 ratings