Skip to content
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

System metrics instrumentation not working with custom defined configuration #1438

Closed
rbagd opened this issue Nov 11, 2022 · 0 comments · Fixed by #1439
Closed

System metrics instrumentation not working with custom defined configuration #1438

rbagd opened this issue Nov 11, 2022 · 0 comments · Fixed by #1439
Labels
bug Something isn't working

Comments

@rbagd
Copy link
Contributor

rbagd commented Nov 11, 2022

System metric instrumentation is not functional if configuration on which metrics to be exported is explicitly provided. As a minimal example, this code

from opentelemetry.metrics import set_meter_provider
from opentelemetry.instrumentation.system_metrics import SystemMetricsInstrumentor
from opentelemetry.sdk.metrics import MeterProvider
from opentelemetry.sdk.metrics.export import (
    ConsoleMetricExporter,
    PeriodicExportingMetricReader,
)

exporter = ConsoleMetricExporter()
set_meter_provider(MeterProvider([PeriodicExportingMetricReader(exporter)]))

configuration = {
    "runtime.memory": ["rss", "vms"],
    "runtime.cpu.time": ["user", "system"],
}

SystemMetricsInstrumentor(config=configuration).instrument()

results in

Traceback (most recent call last):
  File ".../test.py", line 15, in <module>
    SystemMetricsInstrumentor(config=configuration).instrument()
  File ".../lib/python3.10/site-packages/opentelemetry/instrumentation/instrumentor.py", line 51, in __new__
    cls._instance = object.__new__(cls, *args, **kwargs)
TypeError: object.__new__() takes exactly one argument (the type to instantiate)

I am happy to look into fixing this. Removing *args and **kwargs in opentelemetry/instrumentation/instrumentor.py:51 actually solves the issue here but I'd like to understand the implications as this implies changing the interface class.

@rbagd rbagd added the bug Something isn't working label Nov 11, 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