Skip to content

Commit

Permalink
Add trivial test for exemplar filters
Browse files Browse the repository at this point in the history
  • Loading branch information
fcollonval committed Aug 14, 2024
1 parent 6a25608 commit 22cebeb
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions opentelemetry-sdk/tests/metrics/test_exemplarfilter.py
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

0 comments on commit 22cebeb

Please sign in to comment.