Skip to content

TypeError: 'SumAggregation' object is not callable #2478

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

Closed
howardyoo opened this issue Feb 24, 2022 · 0 comments · Fixed by #2391
Closed

TypeError: 'SumAggregation' object is not callable #2478

howardyoo opened this issue Feb 24, 2022 · 0 comments · Fixed by #2391
Labels
bug Something isn't working

Comments

@howardyoo
Copy link
Contributor

Environment
Python 3.9.9 on MacOS Monterey (version 12.2.1) on M1 Arm Architecture

Steps to reproduce

  • clone and install opentelemetry-python repo
  • run the following pip installation
pip install -e ./opentelemetry-sdk
pip install -e ./opentelemetry-api

Run the following test code to test opentelemetry's metric (simple counter)

from re import I
import time
from opentelemetry._metrics import get_meter_provider, set_meter_provider
from opentelemetry.sdk._metrics.export import ConsoleMetricExporter
from opentelemetry.exporter.otlp.proto.grpc._metric_exporter import (
    OTLPMetricExporter,
)
from opentelemetry.sdk._metrics import MeterProvider
from opentelemetry.sdk._metrics.export import PeriodicExportingMetricReader

exporter = ConsoleMetricExporter()

print("setting up metric reader..")
reader = PeriodicExportingMetricReader(exporter=exporter, export_interval_millis=1000)
provider = MeterProvider(metric_readers=[reader])

print("setting meter provider..")
set_meter_provider(provider)

print("getting meter provider..")
# meter = get_meter_provider().get_meter("getting-started")
meter = provider.get_meter("howard")
print(meter)

print("creating counter..")
counter = meter.create_counter("first_counter")
print("adding 1")
counter.add(1)

time.sleep(3)
print("adding 5")
counter.add(5)

time.sleep(5)
print("adding 5")
counter.add(5)

What is the expected behavior?
Expected to see a successful list of metrics being emitted into the console.

What is the actual behavior?
I saw the following error in my script:

setting up metric reader..
setting meter provider..
getting meter provider..
<opentelemetry.sdk._metrics.Meter object at 0x105b192b0>
creating counter..
adding 1
Traceback (most recent call last):
  File "/Users/howardyoo/python/otel/otelmetric.py", line 30, in <module>
    counter.add(1)
  File "/Users/howardyoo/git/opentelemetry-python/opentelemetry-sdk/src/opentelemetry/sdk/_metrics/instrument.py", line 97, in add
    self._measurement_consumer.consume_measurement(
  File "/Users/howardyoo/git/opentelemetry-python/opentelemetry-sdk/src/opentelemetry/sdk/_metrics/measurement_consumer.py", line 61, in consume_measurement
    reader_storage.consume_measurement(measurement)
  File "/Users/howardyoo/git/opentelemetry-python/opentelemetry-sdk/src/opentelemetry/sdk/_metrics/metric_reader_storage.py", line 101, in consume_measurement
    matches.consume_measurement(measurement)
  File "/Users/howardyoo/git/opentelemetry-python/opentelemetry-sdk/src/opentelemetry/sdk/_metrics/_view_instrument_match.py", line 71, in consume_measurement
    self._attributes_aggregation[attributes] = self._aggregation()
TypeError: 'SumAggregation' object is not callable

Additional context
Looks like the line 71 in _view_instrument_match.py had an incorrect '()' at the end of the object's assignment - since the object is not a function, the TypeError: 'SumAggregation' object is not callable was resulted.

@howardyoo howardyoo added the bug Something isn't working label Feb 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant