Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[logs] Rename LogRecordProcessor.emit to on_emit#4648

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
lzchen merged 5 commits intoopen-telemetry:mainfromhectorhdzg:hectorhdzg/onemit
Jun 26, 2025
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletionsCHANGELOG.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -26,6 +26,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
([#4637](https://github.com/open-telemetry/opentelemetry-python/pull/4637))
- Logging API accepts optional `context`; deprecates `trace_id`, `span_id`, `trace_flags`.
([#4597](https://github.com/open-telemetry/opentelemetry-python/pull/4597))
- Rename LogRecordProcessor.emit to on_emit
([#4648](https://github.com/open-telemetry/opentelemetry-python/pull/4648))
- Logging API hide std_to_otel function to convert python logging severity to otel severity
([#4649](https://github.com/open-telemetry/opentelemetry-python/pull/4649))

Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -357,7 +357,7 @@ class LogRecordProcessor(abc.ABC):
"""

@abc.abstractmethod
defemit(self, log_data: LogData):
defon_emit(self, log_data: LogData):
"""Emits the `LogData`"""

@abc.abstractmethod
Expand DownExpand Up@@ -401,9 +401,9 @@ def add_log_record_processor(
with self._lock:
self._log_record_processors += (log_record_processor,)

defemit(self, log_data: LogData) -> None:
defon_emit(self, log_data: LogData) -> None:
for lp in self._log_record_processors:
lp.emit(log_data)
lp.on_emit(log_data)

def shutdown(self) -> None:
"""Shutdown the log processors one by one"""
Expand DownExpand Up@@ -475,8 +475,8 @@ def _submit_and_wait(
for future in futures:
future.result()

defemit(self, log_data: LogData):
self._submit_and_wait(lambda lp: lp.emit, log_data)
defon_emit(self, log_data: LogData):
self._submit_and_wait(lambda lp: lp.on_emit, log_data)

def shutdown(self):
self._submit_and_wait(lambda lp: lp.shutdown)
Expand DownExpand Up@@ -683,7 +683,7 @@ def emit(self, record: LogRecord):
and instrumentation info.
"""
log_data = LogData(record, self._instrumentation_scope)
self._multi_log_record_processor.emit(log_data)
self._multi_log_record_processor.on_emit(log_data)


class LoggerProvider(APILoggerProvider):
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -112,7 +112,7 @@ def __init__(self, exporter: LogExporter):
self._exporter = exporter
self._shutdown = False

defemit(self, log_data: LogData):
defon_emit(self, log_data: LogData):
if self._shutdown:
_logger.warning("Processor is already shutdown, ignoring call")
return
Expand DownExpand Up@@ -186,7 +186,7 @@ def __init__(
"Log",
)

defemit(self, log_data: LogData) -> None:
defon_emit(self, log_data: LogData) -> None:
return self._batch_processor.emit(log_data)

def shutdown(self):
Expand Down
8 changes: 4 additions & 4 deletionsopentelemetry-sdk/tests/logs/test_export.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -348,7 +348,7 @@ def test_emit_call_log_record(self):
logger.addHandler(LoggingHandler(logger_provider=provider))

logger.error("error")
self.assertEqual(log_record_processor.emit.call_count, 1)
self.assertEqual(log_record_processor.on_emit.call_count, 1)
log_record_processor.shutdown()

def test_with_multiple_threads(self): # pylint: disable=no-self-use
Expand All@@ -363,7 +363,7 @@ def test_with_multiple_threads(self): # pylint: disable=no-self-use

def bulk_emit(num_emit):
for _ in range(num_emit):
batch_processor.emit(EMPTY_LOG)
batch_processor.on_emit(EMPTY_LOG)

total_expected_logs = 0
with ThreadPoolExecutor(max_workers=69) as executor:
Expand DownExpand Up@@ -404,10 +404,10 @@ def test_logging_lib_not_invoked_in_batch_log_record_emit(self): # pylint: disa
# If `emit` calls logging.log then this test will throw a maximum recursion depth exceeded exception and fail.
try:
with self.assertNoLogs(sdk_logger, logging.NOTSET):
processor.emit(EMPTY_LOG)
processor.on_emit(EMPTY_LOG)
processor.shutdown()
with self.assertNoLogs(sdk_logger, logging.NOTSET):
processor.emit(EMPTY_LOG)
processor.on_emit(EMPTY_LOG)
finally:
sdk_logger.removeHandler(handler)

Expand Down
2 changes: 1 addition & 1 deletionopentelemetry-sdk/tests/logs/test_handler.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -384,7 +384,7 @@ class FakeProcessor(LogRecordProcessor):
def __init__(self):
self.log_data_emitted = []

defemit(self, log_data: LogData):
defon_emit(self, log_data: LogData):
self.log_data_emitted.append(log_data)

def shutdown(self):
Expand Down
6 changes: 3 additions & 3 deletionsopentelemetry-sdk/tests/logs/test_multi_log_processor.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -38,7 +38,7 @@ def __init__(self, exporter, logs_list):
self._log_list = logs_list
self._closed = False

defemit(self, log_data):
defon_emit(self, log_data):
if self._closed:
return
self._log_list.append(
Expand DownExpand Up@@ -118,9 +118,9 @@ def test_on_emit(self):
for mock in mocks:
multi_log_record_processor.add_log_record_processor(mock)
record = self.make_record()
multi_log_record_processor.emit(record)
multi_log_record_processor.on_emit(record)
for mock in mocks:
mock.emit.assert_called_with(record)
mock.on_emit.assert_called_with(record)
multi_log_record_processor.shutdown()

def test_on_shutdown(self):
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp