-
Notifications
You must be signed in to change notification settings - Fork 703
Ensure the API returns right value types #307
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 all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
ca794fb
enable --strict flag for mypy
3316b2b
Merge remote-tracking branch 'origin/master' into issue-142
6583ad6
Adding test app to both sdk/api
3117a8e
Merge remote-tracking branch 'origin/master' into issue-142
175bb3b
moving --strict to mypy config
2ce41ed
Merge remote-tracking branch 'origin/master' into issue-142
f715c3f
setting default for label_keys in sdk
1fde064
updating int to Optional[int]
3c7b7f0
adding comment to test
a5ae35d
renaming test and test files, fixing typo
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
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
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,54 @@ | ||
# Copyright 2019, 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. | ||
|
||
import unittest | ||
|
||
from opentelemetry import metrics, trace | ||
|
||
|
||
class TestAPIOnlyImplementation(unittest.TestCase): | ||
""" | ||
This test is in place to ensure the API is returning values that | ||
are valid. The same tests have been added to the SDK with | ||
different expected results. See issue for more details: | ||
https://github.com/open-telemetry/opentelemetry-python/issues/142 | ||
""" | ||
|
||
def test_tracer(self): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nice! |
||
tracer = trace.Tracer() | ||
with tracer.start_span("test") as span: | ||
self.assertEqual(span.get_context(), trace.INVALID_SPAN_CONTEXT) | ||
self.assertEqual(span, trace.INVALID_SPAN) | ||
self.assertIs(span.is_recording_events(), False) | ||
with tracer.start_span("test2") as span2: | ||
self.assertEqual( | ||
span2.get_context(), trace.INVALID_SPAN_CONTEXT | ||
) | ||
self.assertEqual(span2, trace.INVALID_SPAN) | ||
self.assertIs(span2.is_recording_events(), False) | ||
|
||
def test_span(self): | ||
span = trace.Span() | ||
self.assertEqual(span.get_context(), trace.INVALID_SPAN_CONTEXT) | ||
self.assertIs(span.is_recording_events(), False) | ||
|
||
def test_default_span(self): | ||
span = trace.DefaultSpan(trace.INVALID_SPAN_CONTEXT) | ||
self.assertEqual(span.get_context(), trace.INVALID_SPAN_CONTEXT) | ||
self.assertIs(span.is_recording_events(), False) | ||
|
||
def test_meter(self): | ||
meter = metrics.Meter() | ||
metric = meter.create_metric("", "", "", float, metrics.Counter) | ||
self.assertIsInstance(metric, metrics.DefaultMetric) |
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
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,53 @@ | ||
# Copyright 2019, 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. | ||
|
||
import unittest | ||
|
||
from opentelemetry.metrics import DefaultMetric | ||
from opentelemetry.sdk import metrics, trace | ||
from opentelemetry.trace import INVALID_SPAN, INVALID_SPAN_CONTEXT | ||
|
||
|
||
class TestSDKImplementation(unittest.TestCase): | ||
""" | ||
This test is in place to ensure the SDK implementation of the API | ||
is returning values that are valid. The same tests have been added | ||
to the API with different expected results. See issue for more details: | ||
https://github.com/open-telemetry/opentelemetry-python/issues/142 | ||
""" | ||
|
||
def test_tracer(self): | ||
tracer = trace.Tracer() | ||
with tracer.start_span("test") as span: | ||
self.assertNotEqual(span.get_context(), INVALID_SPAN_CONTEXT) | ||
self.assertNotEqual(span, INVALID_SPAN) | ||
self.assertIs(span.is_recording_events(), True) | ||
with tracer.start_span("test2") as span2: | ||
self.assertNotEqual(span2.get_context(), INVALID_SPAN_CONTEXT) | ||
self.assertNotEqual(span2, INVALID_SPAN) | ||
self.assertIs(span2.is_recording_events(), True) | ||
|
||
def test_span(self): | ||
with self.assertRaises(Exception): | ||
# pylint: disable=no-value-for-parameter | ||
span = trace.Span() | ||
|
||
span = trace.Span("name", INVALID_SPAN_CONTEXT) | ||
self.assertEqual(span.get_context(), INVALID_SPAN_CONTEXT) | ||
self.assertIs(span.is_recording_events(), True) | ||
|
||
def test_meter(self): | ||
meter = metrics.Meter() | ||
metric = meter.create_metric("", "", "", float, metrics.Counter) | ||
self.assertNotIsInstance(metric, DefaultMetric) |
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.