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

feat(api-metrics): async instruments spec compliance #2569

Merged
merged 10 commits into from
Nov 22, 2021

Conversation

legendecas
Copy link
Member

@legendecas legendecas commented Oct 27, 2021

Which problem is this PR solving?

Fixes #2550
Fixes #2551
Fixes #2553

Depends on #2566

Short description of the changes

  1. Removes ObservableBase.observation
  2. Removes type Observation from api-metrics
  3. Swap callback(3rd parameter) with options(2nd parameteronMeter.createObservable*to markcallback` as a required parameter: a required parameter can not be placed after an optional parameter.
  4. Mark the second parameter label of ObservableResult.observe as optional.

Type of change

  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Checklist:

  • Followed the style guidelines of this project
  • Unit tests have been added
  • Documentation has been updated

@codecov
Copy link

codecov bot commented Oct 27, 2021

Codecov Report

Merging #2569 (d8a666b) into main (9b5feb2) will increase coverage by 0.01%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##             main    #2569      +/-   ##
==========================================
+ Coverage   93.08%   93.10%   +0.01%     
==========================================
  Files         123      123              
  Lines        4761     4758       -3     
  Branches     1061     1061              
==========================================
- Hits         4432     4430       -2     
+ Misses        329      328       -1     
Impacted Files Coverage Δ
...ages/opentelemetry-api-metrics/src/types/Metric.ts 100.00% <0.00%> (ø)
...ackages/opentelemetry-api-metrics/src/NoopMeter.ts 80.55% <0.00%> (+1.06%) ⬆️

# Conflicts:
#	experimental/packages/opentelemetry-api-metrics/src/NoopMeter.ts
#	experimental/packages/opentelemetry-api-metrics/src/types/BatchObserverResult.ts
#	experimental/packages/opentelemetry-api-metrics/src/types/Metric.ts
#	experimental/packages/opentelemetry-sdk-metrics-base/test/Meter.test.ts
@legendecas legendecas marked this pull request as ready for review November 3, 2021 02:31
@legendecas legendecas requested a review from a team November 3, 2021 02:31
Copy link
Member

@dyladan dyladan left a comment

Choose a reason for hiding this comment

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

Have you verified that observables are still useable after this change? By that I mean since you have removed observation does it still export metrics properly.

labels?: Labels,
) => Observation;
}
export type ObservableBase = Record<never, never>;
Copy link
Member

Choose a reason for hiding this comment

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

Record<never, never> only allows the empty object correct?

Copy link
Member Author

Choose a reason for hiding this comment

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

It declares an object type, and it can be extended to have any keys. The reason I use Record here is that the linter rules disallow empty interface interface ObservableBase {}.

};
}
}
export class NoopObservableBaseMetric extends NoopMetric implements ObservableBase {}
Copy link
Member

Choose a reason for hiding this comment

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

Does NoopMetric serve any purpose here or anywhere?

Copy link
Member Author

Choose a reason for hiding this comment

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

Hm, the only use case can be observable instanceof NoopMetric. However, there are no API spec constraints on class hierarchy here, maybe we can remove it.

@legendecas
Copy link
Member Author

@dyladan observation is only being used in batch observers. The observables can work with only ObservableResult:

const observable = meter.createObservableGauge('name', observableResult => {
  observableResult.observe(100, { attr1: 'val' });
});

// we don't have to call `observable.observation(100)` anymore since there is no BatchObserverResult to consume them.

# Conflicts:
#	experimental/packages/opentelemetry-api-metrics/src/types/Metric.ts
#	experimental/packages/opentelemetry-api-metrics/src/types/ObservableResult.ts
#	experimental/packages/opentelemetry-exporter-prometheus/test/PrometheusSerializer.test.ts
#	experimental/packages/opentelemetry-sdk-metrics-base/README.md
@legendecas

This comment has been minimized.

@legendecas legendecas closed this Nov 12, 2021
# Conflicts:
#	experimental/packages/opentelemetry-sdk-metrics-base/README.md
#	experimental/packages/opentelemetry-sdk-metrics-base/src/Meter.ts
#	experimental/packages/opentelemetry-sdk-metrics-base/src/ObservableBaseMetric.ts
#	experimental/packages/opentelemetry-sdk-metrics-base/src/ObservableResult.ts
#	experimental/packages/opentelemetry-sdk-metrics-base/test/Meter.test.ts
@legendecas legendecas reopened this Nov 12, 2021
@legendecas
Copy link
Member Author

So we don't have an updated SDK implementation for the updated API yet and the tests for exporters are complaining about that.

Copy link
Member

@pirgeo pirgeo left a comment

Choose a reason for hiding this comment

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

The changes look good to me, I just wonder: was the Observation not used before?

@vmarchaud
Copy link
Member

So we don't have an updated SDK implementation for the updated API yet and the tests for exporters are complaining about that.

Do we need to ignore tests from exporters while we are working on the metrics api/sdk ? cc @dyladan

@legendecas
Copy link
Member Author

The changes look good to me, I just wonder: was the Observation not used before?

It's being used in batch observers. And batch observers were removed in #2566.

@vmarchaud

This comment has been minimized.

@dyladan
Copy link
Member

dyladan commented Nov 17, 2021

So we don't have an updated SDK implementation for the updated API yet and the tests for exporters are complaining about that.

Do we need to ignore tests from exporters while we are working on the metrics api/sdk ? cc @dyladan

I think we should remove the exporters like we did the SDK. Let's talk about it in SIG

@vmarchaud
Copy link
Member

@legendecas exporter tests are still failing for some reasons :/

@legendecas
Copy link
Member Author

@vmarchaud updated with exporters' changes removed since they are linked to a fixed version of api-metrics.

@vmarchaud vmarchaud merged commit 5e9c7e1 into open-telemetry:main Nov 22, 2021
@legendecas legendecas deleted the metrics-ff/async-instruments branch November 22, 2021 16:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants