-
Notifications
You must be signed in to change notification settings - Fork 659
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add trivial test for exemplar filters
- Loading branch information
1 parent
6a25608
commit 22cebeb
Showing
1 changed file
with
28 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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,28 @@ | ||
from unittest import TestCase | ||
|
||
from opentelemetry.context import Context | ||
from opentelemetry.sdk.metrics._internal.exemplar import ( | ||
AlwaysOffExemplarFilter, | ||
AlwaysOnExemplarFilter, | ||
TraceBasedExemplarFilter, | ||
) | ||
|
||
|
||
class TestAlwaysOnExemplarFilter(TestCase): | ||
def test_should_sample(self): | ||
filter = AlwaysOnExemplarFilter() | ||
self.assertTrue(filter.should_sample(10, 0, {}, Context())) | ||
|
||
|
||
class TestAlwaysOffExemplarFilter(TestCase): | ||
def test_should_sample(self): | ||
filter = AlwaysOffExemplarFilter() | ||
self.assertFalse(filter.should_sample(10, 0, {}, Context())) | ||
|
||
|
||
class TestTraceBasedExemplarFilter(TestCase): | ||
def test_should_not_sample_without_trace(self): | ||
filter = TraceBasedExemplarFilter() | ||
self.assertFalse(filter.should_sample(10, 0, {}, Context())) | ||
|
||
# FIXME add test with trace that should sample |