opentelemetry-operations-python
opentelemetry-operations-python copied to clipboard
BoundedDict was deprecated in opentelemetry-python 1.4.0
Changelog: https://github.com/open-telemetry/opentelemetry-python/blob/main/CHANGELOG.md#version-140023b0-2021-07-21
Used in in https://github.com/GoogleCloudPlatform/opentelemetry-operations-python/blob/773ee41c867f03c062b3be3a5b8d30a32c394f04/opentelemetry-exporter-gcp-trace/src/opentelemetry/exporter/cloud_trace/init.py#L498
Usage of the library will print:
/Users/user/.pyenv/versions/3.9.9/lib/python3.9/site-packages/opentelemetry/exporter/cloud_trace/__init__.py:498: DeprecationWarning: Call to deprecated class BoundedDict. -- Deprecated since version 1.4.0.
] = BoundedDict(num_attrs_limit)
This was just removed from the public API of OTel so should keep warning. I agree we should fix this to stop the log spam, probably just by copying the code for BoundedDict into this repo.
This produces a lot of log noise which we are billed for. I have not been able to figure out how to suppress the warning as a consumer of this package. Is there any chance the warning could be suppressed until a better solution is implemented?
Here's a workaround that suppresses the warning:
import warnings
from opentelemetry.exporter import cloud_trace
class CloudTraceSpanExporterWithoutWarnings(cloud_trace.CloudTraceSpanExporter):
"""Suppresses DeprecationWarning raised by CloudTraceSpanExporter.
See for details:
https://github.com/GoogleCloudPlatform/opentelemetry-operations-python/issues/226
"""
def export(self, *args, **kwargs):
with warnings.catch_warnings():
warnings.simplefilter("ignore", category=DeprecationWarning)
super().export(*args, **kwargs)
opentelemetry-api
/opentelemetry-sdk
v1.16.0 removes a warnings.resetwarnings()
which is what I think was causing these deprecation warnings to have been spamming our logs. As far as I can tell Python does not show these warnings by default and it was that resetwarnings()
call that was removing the default filters.
Glad to see that they resolved the log spam issue but it seems like we should resolve the underlying issue as well.
It looks like opentelemetry.sdk.util.BoundedDict
(sdk) was deprecated in favor of the equivalent class opentelemetry.attributes.BoundedAttributes
(api) here https://github.com/open-telemetry/opentelemetry-python/pull/1915
Would it make more sense to just switch to the new non-deprecated class rather than pulling a copy of the deprecated class into this repo?
The linked PR is not working but glad the log spam has stopped. Can I assign this to you @shevisj ?