File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -327,9 +327,9 @@ def _init_logging(
327327
328328 if setup_logging_handler :
329329 warnings .warn (
330- "Setting the OTel Logging handler from the SDK and the "
331- "`OTEL_PYTHON_LOGGING_AUTO_INSTRUMENTATION_ENABLED` are deprecated. "
332- "You should install the opentelemetry-instrumentation-logging" ,
330+ "The `OTEL_PYTHON_LOGGING_AUTO_INSTRUMENTATION_ENABLED` environment variable "
331+ "and the `LoggingHandler` in `opentelemetry-sdk` that it controls are deprecated."
332+ "Install ` opentelemetry-instrumentation-logging` package instead. " ,
333333 DeprecationWarning ,
334334 )
335335
Original file line number Diff line number Diff line change @@ -497,7 +497,8 @@ def __init__(
497497 self ._logger_provider = logger_provider or get_logger_provider ()
498498
499499 warnings .warn (
500- "This is deprecated you should use the one in opentelemetry-instrumentation-logging" ,
500+ "`LoggingHandler` in `opentelemetry-sdk` is deprecated. Use the "
501+ "handler from `opentelemetry-instrumentation-logging` instead." ,
501502 DeprecationWarning ,
502503 )
503504
Original file line number Diff line number Diff line change 3838
3939# pylint: disable=too-many-public-methods
4040class TestLoggingHandler (unittest .TestCase ):
41+ def test_warns_when_used (self ):
42+ with self .assertWarnsRegex (
43+ DeprecationWarning ,
44+ "`LoggingHandler` in `opentelemetry-sdk` is deprecated" ,
45+ ):
46+ LoggingHandler ()
47+
4148 def test_handler_default_log_level (self ):
4249 processor , logger , handler = set_up_test_logging (logging .NOTSET )
4350
Original file line number Diff line number Diff line change @@ -843,6 +843,18 @@ def test_logging_init_exporter_without_handler_setup(self):
843843 getLogger (__name__ ).error ("hello" )
844844 self .assertFalse (provider .processors [0 ].exporter .export_called )
845845
846+ def test_logging_init_with_setup_logging_handler_to_true_warns (self ):
847+ resource = Resource .create ({})
848+ with self .assertWarnsRegex (
849+ DeprecationWarning ,
850+ "and the `LoggingHandler` in `opentelemetry-sdk` that it controls are deprecated" ,
851+ ):
852+ _init_logging (
853+ {"otlp" : DummyOTLPLogExporter },
854+ resource = resource ,
855+ setup_logging_handler = True ,
856+ )
857+
846858 @patch .dict (
847859 environ ,
848860 {"OTEL_RESOURCE_ATTRIBUTES" : "service.name=otlp-service" },
You can’t perform that action at this time.
0 commit comments