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

fix(metrics): collect gauge values asynchronously #213

Closed

Commits on Apr 4, 2023

  1. fix(metrics): collect gauge values asynchronously

    When using the "otel" collector for metrics-reporter.
    You will get a log message like:
    
       WARNING: Instrument X has recorded multiple values for the same attributes.
    
    This is because the Gauge builder in the OpenTelemetry Java SDK can only
    collect gauge values asynchronously.
    
    The old code essentially redefined the gauge every time with a callback
    that produces the same value. The first registration succeeds since
    there is no gauge defined; but subsequent gauge updates failed because
    of the duplicate attributes.
    
    This fix attempts to solve this by using a synchronous map and only
    defining the gauge once. The callback uses the sync map to get the
    latest value. Subsequent calls to gauge update the value in the map
    rather than re-defining the gauge again.
    
    This sort of a hack. The way that the API of OpenTelemetry is designed
    is such that you should define your gauge up-front, passing a callback
    which would perform the measurements periodically  by the SDK.
    However, this API does not conform to the MetricClient interface
    so this adapter is necessary unless the metrics client is refactored
    to support this use-case.
    
    Fixes #15623
    justenwalker committed Apr 4, 2023
    Configuration menu
    Copy the full SHA
    4d84fcd View commit details
    Browse the repository at this point in the history
  2. refactor: add comments to explain implementation

    - Add some comments to explain the implementation and why it is done
      this way.
    - A little refactoring of the method body
    justenwalker committed Apr 4, 2023
    Configuration menu
    Copy the full SHA
    5ae440e View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    0f0f842 View commit details
    Browse the repository at this point in the history

Commits on Apr 5, 2023

  1. Configuration menu
    Copy the full SHA
    6f3df43 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    338816c View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    4a33733 View commit details
    Browse the repository at this point in the history