Skip to content

Commit 7aac5b0

Browse files
committed
Feedback: drop warnings that have a deprecations
1 parent bc8887b commit 7aac5b0

File tree

6 files changed

+5
-165
lines changed

6 files changed

+5
-165
lines changed

opentelemetry-sdk/src/opentelemetry/sdk/_logs/_internal/__init__.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -147,12 +147,6 @@ def __init__(
147147
OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT,
148148
)
149149

150-
warnings.warn(
151-
"LogLimits will be deprecated in 1.39.0 and then renamed to LogRecordLimits",
152-
LogDeprecatedInitWarning,
153-
stacklevel=0,
154-
)
155-
156150
def __repr__(self):
157151
return f"{type(self).__name__}(max_attributes={self.max_attributes}, max_attribute_length={self.max_attribute_length})"
158152

@@ -370,7 +364,7 @@ def __init__(
370364
instrumentation_scope: InstrumentationScope,
371365
):
372366
warnings.warn(
373-
"LogData will be substituted in 1.39.0 by ReadWriteLogRecord and ReadableLogRecord",
367+
"LogData will be removed in 1.39.0 and replaced by ReadWriteLogRecord and ReadableLogRecord",
374368
LogDeprecatedInitWarning,
375369
stacklevel=0,
376370
)

opentelemetry-sdk/src/opentelemetry/sdk/_logs/_internal/export/__init__.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
import enum
1818
import logging
1919
import sys
20-
import warnings
2120
from os import environ, linesep
2221
from typing import IO, Callable, Optional, Sequence
2322

@@ -29,7 +28,6 @@
2928
)
3029
from opentelemetry.sdk._logs import (
3130
LogData,
32-
LogDeprecatedInitWarning,
3331
LogRecord,
3432
LogRecordProcessor,
3533
)
@@ -99,12 +97,6 @@ def __init__(
9997
self.out = out
10098
self.formatter = formatter
10199

102-
warnings.warn(
103-
"ConsoleLogExporter will be deprecated in 1.39.0 and then renamed to ConsoleLogRecordExporter",
104-
LogDeprecatedInitWarning,
105-
stacklevel=0,
106-
)
107-
108100
def export(self, batch: Sequence[LogData]):
109101
for data in batch:
110102
self.out.write(self.formatter(data.log_record))

opentelemetry-sdk/src/opentelemetry/sdk/_logs/_internal/export/in_memory_log_exporter.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,8 @@
1414

1515
import threading
1616
import typing
17-
import warnings
1817

19-
from opentelemetry.sdk._logs import LogData, LogDeprecatedInitWarning
18+
from opentelemetry.sdk._logs import LogData
2019
from opentelemetry.sdk._logs.export import LogExporter, LogExportResult
2120

2221

@@ -33,12 +32,6 @@ def __init__(self):
3332
self._lock = threading.Lock()
3433
self._stopped = False
3534

36-
warnings.warn(
37-
"InMemoryLogExporter will be deprecated in 1.39.0 and then renamed to InMemoryLogRecordExporter",
38-
LogDeprecatedInitWarning,
39-
stacklevel=0,
40-
)
41-
4235
def clear(self) -> None:
4336
with self._lock:
4437
self._logs.clear()

opentelemetry-sdk/tests/logs/test_export.py

Lines changed: 0 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
import os
1818
import time
1919
import unittest
20-
import warnings
2120
from concurrent.futures import ThreadPoolExecutor
2221
from sys import version_info
2322
from unittest.mock import Mock, patch
@@ -28,7 +27,6 @@
2827
from opentelemetry.sdk import trace
2928
from opentelemetry.sdk._logs import (
3029
LogData,
31-
LogDeprecatedInitWarning,
3230
LoggerProvider,
3331
LoggingHandler,
3432
LogRecord,
@@ -649,99 +647,3 @@ def formatter(record): # pylint: disable=unused-argument
649647
exporter.export([EMPTY_LOG])
650648

651649
mock_stdout.write.assert_called_once_with(mock_record_str)
652-
653-
def test_console_log_exporter_deprecated_warning(self):
654-
"""Test that ConsoleLogExporter initialization emits a deprecation warning."""
655-
with warnings.catch_warnings(record=True) as cw:
656-
warnings.simplefilter("always")
657-
ConsoleLogExporter()
658-
659-
# Check that at least one LogDeprecatedInitWarning, was emitted
660-
console_warnings = [
661-
w for w in cw if isinstance(w.message, LogDeprecatedInitWarning)
662-
]
663-
self.assertGreater(
664-
len(console_warnings),
665-
0,
666-
"Expected at least one LogDeprecatedInitWarning",
667-
)
668-
669-
# Check the message content of the warning
670-
warning_message = str(console_warnings[0].message)
671-
self.assertIn(
672-
"ConsoleLogExporter will be deprecated in 1.39.0 and then renamed to ConsoleLogRecordExporter",
673-
warning_message,
674-
)
675-
676-
def test_console_log_exporter_deprecated_warning_once(self):
677-
"""Test that ConsoleLogExporter deprecation warning is only shown once due to simplefilter('once')."""
678-
with warnings.catch_warnings(record=True) as cw:
679-
# Multiple instantiations should only warn once due to simplefilter("once")
680-
for _ in range(10):
681-
ConsoleLogExporter()
682-
683-
# Check that exactly one LogDeprecatedInitWarning was emitted
684-
console_warnings = [
685-
w for w in cw if isinstance(w.message, LogDeprecatedInitWarning)
686-
]
687-
self.assertEqual(
688-
len(console_warnings),
689-
1,
690-
"Expected exactly one LogDeprecatedInitWarning due to simplefilter('once')",
691-
)
692-
693-
# Check the message content
694-
warning_message = str(console_warnings[0].message)
695-
self.assertIn(
696-
"ConsoleLogExporter will be deprecated in 1.39.0 and then renamed to ConsoleLogRecordExporter",
697-
warning_message,
698-
)
699-
700-
701-
class TestInMemoryLogExporterDeprecation(unittest.TestCase):
702-
def test_in_memory_log_exporter_deprecated_warning(self):
703-
"""Test that InMemoryLogExporter initialization emits a deprecation warning."""
704-
with warnings.catch_warnings(record=True) as cw:
705-
warnings.simplefilter("always")
706-
InMemoryLogExporter()
707-
708-
# Check that at least one LogDeprecatedInitWarning was emitted
709-
in_memory_warnings = [
710-
w for w in cw if isinstance(w.message, LogDeprecatedInitWarning)
711-
]
712-
self.assertGreater(
713-
len(in_memory_warnings),
714-
0,
715-
"Expected at least one LogDeprecatedInitWarning",
716-
)
717-
718-
# Check the message content of the warning
719-
warning_message = str(in_memory_warnings[0].message)
720-
self.assertIn(
721-
"InMemoryLogExporter will be deprecated in 1.39.0 and then renamed to InMemoryLogRecordExporter",
722-
warning_message,
723-
)
724-
725-
def test_in_memory_log_exporter_deprecated_warning_once(self):
726-
"""Test that InMemoryLogExporter deprecation warning is only shown once due to simplefilter('once')."""
727-
with warnings.catch_warnings(record=True) as cw:
728-
# Multiple instantiations should only warn once due to simplefilter("once")
729-
for _ in range(10):
730-
InMemoryLogExporter()
731-
732-
# Check that exactly one LogDeprecatedInitWarning was emitted
733-
in_memory_warnings = [
734-
w for w in cw if isinstance(w.message, LogDeprecatedInitWarning)
735-
]
736-
self.assertEqual(
737-
len(in_memory_warnings),
738-
1,
739-
"Expected exactly one LogDeprecatedInitWarning due to simplefilter('once')",
740-
)
741-
742-
# Check the message content
743-
warning_message = str(in_memory_warnings[0].message)
744-
self.assertIn(
745-
"InMemoryLogExporter will be deprecated in 1.39.0 and then renamed to InMemoryLogRecordExporter",
746-
warning_message,
747-
)

opentelemetry-sdk/tests/logs/test_log_limits.py

Lines changed: 1 addition & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,9 @@
1313
# limitations under the License.
1414

1515
import unittest
16-
import warnings
1716
from unittest.mock import patch
1817

19-
from opentelemetry.sdk._logs import LogDeprecatedInitWarning, LogLimits
18+
from opentelemetry.sdk._logs import LogLimits
2019
from opentelemetry.sdk._logs._internal import (
2120
_DEFAULT_OTEL_ATTRIBUTE_COUNT_LIMIT,
2221
)
@@ -71,43 +70,3 @@ def test_invalid_env_vars_raise(self):
7170
str(error.exception),
7271
f"Unexpected error message for {env_var}={bad_value}",
7372
)
74-
75-
def test_log_limits_init_deprecated_warning(self):
76-
"""Test that LogLimits initialization emits a deprecation warning."""
77-
with warnings.catch_warnings(record=True) as cw:
78-
warnings.simplefilter("always")
79-
LogLimits()
80-
81-
self.assertEqual(len(cw), 1)
82-
self.assertIsInstance(cw[-1].message, LogDeprecatedInitWarning)
83-
self.assertIn(
84-
"LogLimits will be deprecated in 1.39.0 and then renamed to LogRecordLimits",
85-
str(cw[-1].message),
86-
)
87-
88-
def test_log_limits_init_deprecated_warning_with_params(self):
89-
"""Test that LogLimits initialization with parameters still emits a deprecation warning."""
90-
with warnings.catch_warnings(record=True) as cw:
91-
warnings.simplefilter("always")
92-
LogLimits(max_attributes=10, max_attribute_length=100)
93-
94-
self.assertEqual(len(cw), 1)
95-
self.assertIsInstance(cw[-1].message, LogDeprecatedInitWarning)
96-
self.assertIn(
97-
"LogLimits will be deprecated in 1.39.0 and then renamed to LogRecordLimits",
98-
str(cw[-1].message),
99-
)
100-
101-
def test_log_limits_init_deprecated_warning_once(self):
102-
"""Test that LogLimits deprecation warning is only shown once due to simplefilter('once')."""
103-
with warnings.catch_warnings(record=True) as cw:
104-
# Multiple instantiations should only warn once due to simplefilter("once")
105-
for _ in range(10):
106-
LogLimits()
107-
108-
self.assertEqual(len(cw), 1)
109-
self.assertIsInstance(cw[-1].message, LogDeprecatedInitWarning)
110-
self.assertIn(
111-
"LogLimits will be deprecated in 1.39.0 and then renamed to LogRecordLimits",
112-
str(cw[-1].message),
113-
)

opentelemetry-sdk/tests/logs/test_log_record.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ def test_log_record_context_deprecated_init_warning(self):
189189
for w in cw
190190
if isinstance(w.message, LogDeprecatedInitWarning)
191191
]
192-
self.assertEqual(len(context_deprecated_warnings), 3)
192+
self.assertEqual(len(context_deprecated_warnings), 2)
193193

194194
# Check we have the expected message once
195195
log_record_context_warning = [
@@ -209,7 +209,7 @@ def test_log_record_context_deprecated_init_warning(self):
209209
context_deprecated_warnings = [
210210
w for w in cw if isinstance(w.message, LogDeprecatedInitWarning)
211211
]
212-
self.assertEqual(len(context_deprecated_warnings), 2)
212+
self.assertEqual(len(context_deprecated_warnings), 1)
213213

214214
# Check we have no message
215215
log_record_context_warning = [

0 commit comments

Comments
 (0)