Skip to content

Commit

Permalink
Fix histogram test
Browse files Browse the repository at this point in the history
  • Loading branch information
ocelotl committed Sep 6, 2023
1 parent 6f04ff8 commit e4b44ae
Showing 1 changed file with 10 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,25 @@

from unittest import TestCase

from opentelemetry.metrics import set_meter_provider
from opentelemetry.sdk.metrics import MeterProvider
from opentelemetry.sdk.metrics.export import InMemoryMetricReader
from opentelemetry.sdk.resources import SERVICE_NAME, Resource

in_memory_metric_reader = InMemoryMetricReader()

provider = MeterProvider(
resource=Resource.create({SERVICE_NAME: "otel-test"}),
metric_readers=[in_memory_metric_reader],
)
set_meter_provider(provider)

meter = provider.get_meter("my-meter")
class TestHistogramExport(TestCase):
def test_histogram_counter_collection(self):

histogram = meter.create_histogram("my_histogram")
counter = meter.create_counter("my_counter")
in_memory_metric_reader = InMemoryMetricReader()

provider = MeterProvider(
resource=Resource.create({SERVICE_NAME: "otel-test"}),
metric_readers=[in_memory_metric_reader],
)

class TestHistogramExport(TestCase):
def test_histogram_counter_collection(self):
meter = provider.get_meter("my-meter")

histogram = meter.create_histogram("my_histogram")
counter = meter.create_counter("my_counter")
histogram.record(5, {"attribute": "value"})
counter.add(1, {"attribute": "value_counter"})

Expand Down

0 comments on commit e4b44ae

Please sign in to comment.