-
Notifications
You must be signed in to change notification settings - Fork 705
Make create_gauge
non-abstract method
#3817
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
Merged
Merged
Changes from 3 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
45f1935
Make create_gauge non-abstract method
srikanthccv 3771bd1
Update test_subclass_instantiation.py
srikanthccv 50ff88a
Merge branch 'main' into issue-3710
srikanthccv 1c0b28b
Fix lint
srikanthccv a710329
Merge branch 'issue-3710' of github.com:srikanthccv/opentelemetry-pyt…
srikanthccv 4b46293
Actually fix lint
srikanthccv 1a92c8d
This time we actually fix lint
srikanthccv File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
165 changes: 165 additions & 0 deletions
165
opentelemetry-api/tests/metrics/test_subclass_instantiation.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,165 @@ | ||
# Copyright The OpenTelemetry Authors | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# type: ignore | ||
|
||
# NOTE: The tests in this file are intended to test the semver compatibility of the public API. | ||
# Any tests that fail here indicate that the public API has changed in a way that is not backwards compatible. | ||
# Either bump the major version of the API, or make the necessary changes to the API to remain semver compatible. | ||
|
||
from opentelemetry.metrics import ( | ||
Meter, | ||
MeterProvider, | ||
Synchronous, | ||
Asynchronous, | ||
Counter, | ||
_Gauge, | ||
Histogram, | ||
Instrument, | ||
ObservableCounter, | ||
ObservableGauge, | ||
ObservableUpDownCounter, | ||
UpDownCounter, | ||
) | ||
|
||
class MeterProviderImplTest(MeterProvider): | ||
def get_meter(self, name: str, version: str | None = None, schema_url: str | None = None) -> Meter: | ||
return super().get_meter(name, version, schema_url) | ||
|
||
def test_meter_provider_subclass_instantiation(): | ||
meter_provider = MeterProviderImplTest() | ||
assert isinstance(meter_provider, MeterProvider) | ||
|
||
class MeterImplTest(Meter): | ||
def create_counter(self, name, description, **kwargs): | ||
pass | ||
|
||
def create_up_down_counter(self, name, description, **kwargs): | ||
pass | ||
|
||
def create_observable_counter(self, name, description, **kwargs): | ||
pass | ||
|
||
def create_histogram(self, name, description, **kwargs): | ||
pass | ||
|
||
def create_observable_gauge(self, name, description, **kwargs): | ||
pass | ||
|
||
def create_observable_up_down_counter(self, name, description, **kwargs): | ||
pass | ||
|
||
def test_meter_subclass_instantiation(): | ||
meter = MeterImplTest("subclass_test") | ||
assert isinstance(meter, Meter) | ||
|
||
class SynchronousImplTest(Synchronous): | ||
def __init__(self, name: str, unit: str = "", description: str = "") -> None: | ||
super().__init__(name, unit, description) | ||
|
||
def test_synchronous_subclass_instantiation(): | ||
synchronous = SynchronousImplTest("subclass_test") | ||
assert isinstance(synchronous, Synchronous) | ||
|
||
class AsynchronousImplTest(Asynchronous): | ||
def __init__(self, name: str, unit: str = "", description: str = "") -> None: | ||
super().__init__(name, unit, description) | ||
|
||
def test_asynchronous_subclass_instantiation(): | ||
asynchronous = AsynchronousImplTest("subclass_test") | ||
assert isinstance(asynchronous, Asynchronous) | ||
|
||
class CounterImplTest(Counter): | ||
def __init__(self, name: str, unit: str = "", description: str = "") -> None: | ||
super().__init__(name, unit, description) | ||
|
||
def add(self, amount: int, **kwargs): | ||
pass | ||
|
||
def test_counter_subclass_instantiation(): | ||
counter = CounterImplTest("subclass_test") | ||
assert isinstance(counter, Counter) | ||
|
||
class UpDownCounterImplTest(UpDownCounter): | ||
def __init__(self, name: str, unit: str = "", description: str = "") -> None: | ||
super().__init__(name, unit, description) | ||
|
||
def add(self, amount: int, **kwargs): | ||
pass | ||
|
||
def test_up_down_counter_subclass_instantiation(): | ||
up_down_counter = UpDownCounterImplTest("subclass_test") | ||
assert isinstance(up_down_counter, UpDownCounter) | ||
|
||
class ObservableCounterImplTest(ObservableCounter): | ||
def __init__(self, name: str, unit: str = "", description: str = "") -> None: | ||
super().__init__(name, unit, description) | ||
|
||
def test_observable_counter_subclass_instantiation(): | ||
observable_counter = ObservableCounterImplTest("subclass_test") | ||
assert isinstance(observable_counter, ObservableCounter) | ||
|
||
class HistogramImplTest(Histogram): | ||
def __init__(self, name: str, unit: str = "", description: str = "") -> None: | ||
super().__init__(name, unit, description) | ||
|
||
def record(self, amount: int, **kwargs): | ||
pass | ||
|
||
def test_histogram_subclass_instantiation(): | ||
histogram = HistogramImplTest("subclass_test") | ||
assert isinstance(histogram, Histogram) | ||
|
||
class GaugeImplTest(_Gauge): | ||
def __init__(self, name: str, unit: str = "", description: str = "") -> None: | ||
super().__init__(name, unit, description) | ||
|
||
def set(self, amount: int, **kwargs): | ||
pass | ||
|
||
def test_gauge_subclass_instantiation(): | ||
gauge = GaugeImplTest("subclass_test") | ||
assert isinstance(gauge, _Gauge) | ||
|
||
class InstrumentImplTest(Instrument): | ||
def __init__(self, name: str, unit: str = "", description: str = "") -> None: | ||
super().__init__(name, unit, description) | ||
|
||
def test_instrument_subclass_instantiation(): | ||
instrument = InstrumentImplTest("subclass_test") | ||
assert isinstance(instrument, Instrument) | ||
|
||
class ObservableGaugeImplTest(ObservableGauge): | ||
def __init__(self, name: str, unit: str = "", description: str = "") -> None: | ||
super().__init__(name, unit, description) | ||
|
||
def test_observable_gauge_subclass_instantiation(): | ||
observable_gauge = ObservableGaugeImplTest("subclass_test") | ||
assert isinstance(observable_gauge, ObservableGauge) | ||
|
||
class ObservableUpDownCounterImplTest(ObservableUpDownCounter): | ||
def __init__(self, name: str, unit: str = "", description: str = "") -> None: | ||
super().__init__(name, unit, description) | ||
|
||
def test_observable_up_down_counter_subclass_instantiation(): | ||
observable_up_down_counter = ObservableUpDownCounterImplTest("subclass_test") | ||
assert isinstance(observable_up_down_counter, ObservableUpDownCounter) | ||
|
||
class ObservableUpDownCounterImplTest(ObservableUpDownCounter): | ||
def __init__(self, name: str, unit: str = "", description: str = "") -> None: | ||
super().__init__(name, unit, description) | ||
|
||
def test_observable_up_down_counter_subclass_instantiation(): | ||
observable_up_down_counter = ObservableUpDownCounterImplTest("subclass_test") | ||
assert isinstance(observable_up_down_counter, ObservableUpDownCounter) | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.