Skip to content

Commit 0c2a4a0

Browse files
committed
different classes
1 parent 41386df commit 0c2a4a0

File tree

4 files changed

+82
-12
lines changed

4 files changed

+82
-12
lines changed

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

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,12 @@
1515

1616
from opentelemetry.sdk._logs._internal import (
1717
LogData,
18-
LogDeprecatedInitWarning,
18+
LogLimitsInitDeprecatedWarning,
19+
LogRecordInitDeprecatedWarning,
20+
LogDataInitDeprecatedWarning,
21+
LogRecordContextDeprecatedWarning,
22+
InMemoryLogExporterDeprecatedWarning,
23+
ConsoleLogExporterDeprecatedWarning,
1924
LogDroppedAttributesWarning,
2025
Logger,
2126
LoggerProvider,
@@ -33,6 +38,11 @@
3338
"LogLimits",
3439
"LogRecord",
3540
"LogRecordProcessor",
36-
"LogDeprecatedInitWarning",
41+
"LogLimitsInitDeprecatedWarning",
42+
"LogRecordInitDeprecatedWarning",
3743
"LogDroppedAttributesWarning",
44+
"LogDataInitDeprecatedWarning",
45+
"LogRecordContextDeprecatedWarning",
46+
"InMemoryLogExporterDeprecatedWarning",
47+
"ConsoleLogExporterDeprecatedWarning",
3848
]

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

Lines changed: 66 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,19 @@ class LogDroppedAttributesWarning(UserWarning):
8484
warnings.simplefilter("once", LogDroppedAttributesWarning)
8585

8686

87-
class LogDeprecatedInitWarning(UserWarning):
87+
class LogLimitsInitDeprecatedWarning(UserWarning):
88+
"""Custom warning to indicate deprecated LogLimits init was used.
89+
90+
This class is used to filter and handle these specific warnings separately
91+
from other warnings, ensuring that they are only shown once without
92+
interfering with default user warnings.
93+
"""
94+
95+
96+
warnings.simplefilter("once", LogLimitsInitDeprecatedWarning)
97+
98+
99+
class LogRecordInitDeprecatedWarning(UserWarning):
88100
"""Custom warning to indicate deprecated LogRecord init was used.
89101
90102
This class is used to filter and handle these specific warnings separately
@@ -93,7 +105,55 @@ class LogDeprecatedInitWarning(UserWarning):
93105
"""
94106

95107

96-
warnings.simplefilter("once", LogDeprecatedInitWarning)
108+
warnings.simplefilter("once", LogRecordInitDeprecatedWarning)
109+
110+
111+
class LogDataInitDeprecatedWarning(UserWarning):
112+
"""Custom warning to indicate deprecated LogData init was used.
113+
114+
This class is used to filter and handle these specific warnings separately
115+
from other warnings, ensuring that they are only shown once without
116+
interfering with default user warnings.
117+
"""
118+
119+
120+
warnings.simplefilter("once", LogDataInitDeprecatedWarning)
121+
122+
123+
class LogRecordContextDeprecatedWarning(UserWarning):
124+
"""Custom warning to indicate LogRecord was initialized without using context.
125+
126+
This class is used to filter and handle these specific warnings separately
127+
from other warnings, ensuring that they are only shown once without
128+
interfering with default user warnings.
129+
"""
130+
131+
132+
warnings.simplefilter("once", LogRecordContextDeprecatedWarning)
133+
134+
135+
class InMemoryLogExporterDeprecatedWarning(UserWarning):
136+
"""Custom warning to indicate InMemoryLogExporter is deprecated.
137+
138+
This class is used to filter and handle these specific warnings separately
139+
from other warnings, ensuring that they are only shown once without
140+
interfering with default user warnings.
141+
"""
142+
143+
144+
warnings.simplefilter("once", LogRecordContextDeprecatedWarning)
145+
146+
147+
class ConsoleLogExporterDeprecatedWarning(UserWarning):
148+
"""Custom warning to indicate ConsoleLogExporter is deprecated.
149+
150+
This class is used to filter and handle these specific warnings separately
151+
from other warnings, ensuring that they are only shown once without
152+
interfering with default user warnings.
153+
"""
154+
155+
156+
warnings.simplefilter("once", ConsoleLogExporterDeprecatedWarning)
97157

98158

99159
class LogLimits:
@@ -149,7 +209,7 @@ def __init__(
149209

150210
warnings.warn(
151211
"LogLimits will be deprecated in 1.39.0 and then renamed to LogRecordLimits",
152-
LogDeprecatedInitWarning,
212+
LogLimitsInitDeprecatedWarning,
153213
stacklevel=0,
154214
)
155215

@@ -242,7 +302,7 @@ def __init__( # pylint:disable=too-many-locals
242302
):
243303
warnings.warn(
244304
"LogRecord will be substituted in 1.39.0 by ReadWriteLogRecord and ReadableLogRecord",
245-
LogDeprecatedInitWarning,
305+
LogRecordInitDeprecatedWarning,
246306
stacklevel=0,
247307
)
248308
if not context:
@@ -251,7 +311,7 @@ def __init__( # pylint:disable=too-many-locals
251311
if trace_id or span_id or trace_flags:
252312
warnings.warn(
253313
"LogRecord init with `trace_id`, `span_id`, and/or `trace_flags` is deprecated since 1.35.0. Use `context` instead.",
254-
LogDeprecatedInitWarning,
314+
LogRecordContextDeprecatedWarning,
255315
stacklevel=2,
256316
)
257317

@@ -371,7 +431,7 @@ def __init__(
371431
):
372432
warnings.warn(
373433
"LogData will be substituted in 1.39.0 by ReadWriteLogRecord and ReadableLogRecord",
374-
LogDeprecatedInitWarning,
434+
LogDataInitDeprecatedWarning,
375435
stacklevel=0,
376436
)
377437
self.log_record = log_record

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
)
3030
from opentelemetry.sdk._logs import (
3131
LogData,
32-
LogDeprecatedInitWarning,
32+
ConsoleLogExporterDeprecatedWarning,
3333
LogRecord,
3434
LogRecordProcessor,
3535
)
@@ -101,7 +101,7 @@ def __init__(
101101

102102
warnings.warn(
103103
"ConsoleLogExporter will be deprecated in 1.39.0 and then renamed to ConsoleLogRecordExporter",
104-
LogDeprecatedInitWarning,
104+
ConsoleLogExporterDeprecatedWarning,
105105
stacklevel=0,
106106
)
107107

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import typing
1717
import warnings
1818

19-
from opentelemetry.sdk._logs import LogData, LogDeprecatedInitWarning
19+
from opentelemetry.sdk._logs import LogData, InMemoryLogExporterDeprecatedWarning
2020
from opentelemetry.sdk._logs.export import LogExporter, LogExportResult
2121

2222

@@ -35,7 +35,7 @@ def __init__(self):
3535

3636
warnings.warn(
3737
"InMemoryLogExporter will be deprecated in 1.39.0 and then renamed to InMemoryLogRecordExporter",
38-
LogDeprecatedInitWarning,
38+
InMemoryLogExporterDeprecatedWarning,
3939
stacklevel=0,
4040
)
4141

0 commit comments

Comments
 (0)