Skip to content

Commit 22cebeb

Browse files
committed
Add trivial test for exemplar filters
1 parent 6a25608 commit 22cebeb

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
from unittest import TestCase
2+
3+
from opentelemetry.context import Context
4+
from opentelemetry.sdk.metrics._internal.exemplar import (
5+
AlwaysOffExemplarFilter,
6+
AlwaysOnExemplarFilter,
7+
TraceBasedExemplarFilter,
8+
)
9+
10+
11+
class TestAlwaysOnExemplarFilter(TestCase):
12+
def test_should_sample(self):
13+
filter = AlwaysOnExemplarFilter()
14+
self.assertTrue(filter.should_sample(10, 0, {}, Context()))
15+
16+
17+
class TestAlwaysOffExemplarFilter(TestCase):
18+
def test_should_sample(self):
19+
filter = AlwaysOffExemplarFilter()
20+
self.assertFalse(filter.should_sample(10, 0, {}, Context()))
21+
22+
23+
class TestTraceBasedExemplarFilter(TestCase):
24+
def test_should_not_sample_without_trace(self):
25+
filter = TraceBasedExemplarFilter()
26+
self.assertFalse(filter.should_sample(10, 0, {}, Context()))
27+
28+
# FIXME add test with trace that should sample

0 commit comments

Comments
 (0)