Skip to content

Commit

Permalink
move logs to _logs (#2240)
Browse files Browse the repository at this point in the history
* move logs to _logs

* fix lint
  • Loading branch information
Alex Boten committed Oct 29, 2021
1 parent 24b5517 commit 0cd439f
Show file tree
Hide file tree
Showing 15 changed files with 46 additions and 44 deletions.
4 changes: 2 additions & 2 deletions docs/examples/logs/example.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

from opentelemetry import trace
from opentelemetry.exporter.otlp.proto.grpc.log_exporter import OTLPLogExporter
from opentelemetry.sdk.logs import (
from opentelemetry.sdk._logs import (
LogEmitterProvider,
OTLPHandler,
set_log_emitter_provider,
)
from opentelemetry.sdk.logs.export import BatchLogProcessor
from opentelemetry.sdk._logs.export import BatchLogProcessor
from opentelemetry.sdk.resources import Resource
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import (
Expand Down
8 changes: 4 additions & 4 deletions docs/sdk/logs.export.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
opentelemetry.sdk.logs.export
=============================
opentelemetry.sdk._logs.export
==============================

.. automodule:: opentelemetry.sdk.logs.export
.. automodule:: opentelemetry.sdk._logs.export
:members:
:undoc-members:
:show-inheritance:
:show-inheritance:
4 changes: 2 additions & 2 deletions docs/sdk/logs.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
opentelemetry.sdk.logs package
opentelemetry.sdk._logs package
===============================

Submodules
Expand All @@ -9,7 +9,7 @@ Submodules
logs.export
logs.severity

.. automodule:: opentelemetry.sdk.logs
.. automodule:: opentelemetry.sdk._logs
:members:
:undoc-members:
:show-inheritance:
6 changes: 3 additions & 3 deletions docs/sdk/logs.severity.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
opentelemetry.sdk.logs.severity
===============================
opentelemetry.sdk._logs.severity
================================

.. automodule:: opentelemetry.sdk.logs.severity
.. automodule:: opentelemetry.sdk._logs.severity
:members:
:undoc-members:
:show-inheritance:
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@
ResourceLogs,
)
from opentelemetry.proto.logs.v1.logs_pb2 import LogRecord as PB2LogRecord
from opentelemetry.sdk.logs import LogRecord as SDKLogRecord
from opentelemetry.sdk.logs import LogData
from opentelemetry.sdk.logs.export import LogExporter, LogExportResult
from opentelemetry.sdk._logs import LogRecord as SDKLogRecord
from opentelemetry.sdk._logs import LogData
from opentelemetry.sdk._logs.export import LogExporter, LogExportResult


class OTLPLogExporter(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,11 @@
from opentelemetry.proto.resource.v1.resource_pb2 import (
Resource as OTLPResource,
)
from opentelemetry.sdk.logs import LogData, LogRecord
from opentelemetry.sdk.logs.export import LogExportResult
from opentelemetry.sdk.logs.severity import SeverityNumber as SDKSeverityNumber
from opentelemetry.sdk._logs import LogData, LogRecord
from opentelemetry.sdk._logs.export import LogExportResult
from opentelemetry.sdk._logs.severity import (
SeverityNumber as SDKSeverityNumber,
)
from opentelemetry.sdk.resources import Resource as SDKResource
from opentelemetry.sdk.util.instrumentation import InstrumentationInfo
from opentelemetry.trace import TraceFlags
Expand Down
2 changes: 1 addition & 1 deletion opentelemetry-sdk/setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ opentelemetry_tracer_provider =
opentelemetry_traces_exporter =
console = opentelemetry.sdk.trace.export:ConsoleSpanExporter
opentelemetry_log_emitter_provider =
sdk_log_emitter_provider = opentelemetry.sdk.logs:LogEmitterProvider
sdk_log_emitter_provider = opentelemetry.sdk._logs:LogEmitterProvider
opentelemetry_id_generator =
random = opentelemetry.sdk.trace.id_generator:RandomIdGenerator
opentelemetry_environment_variables =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
import threading
from typing import Any, Callable, Optional, Tuple, Union, cast

from opentelemetry.sdk._logs.severity import SeverityNumber, std_to_otlp
from opentelemetry.sdk.environment_variables import (
OTEL_PYTHON_LOG_EMITTER_PROVIDER,
)
from opentelemetry.sdk.logs.severity import SeverityNumber, std_to_otlp
from opentelemetry.sdk.resources import Resource
from opentelemetry.sdk.util import ns_to_iso_str
from opentelemetry.sdk.util.instrumentation import InstrumentationInfo
Expand Down Expand Up @@ -124,7 +124,7 @@ def emit(self, log_data: LogData):

@abc.abstractmethod
def shutdown(self):
"""Called when a :class:`opentelemetry.sdk.logs.LogEmitter` is shutdown"""
"""Called when a :class:`opentelemetry.sdk._logs.LogEmitter` is shutdown"""

@abc.abstractmethod
def force_flush(self, timeout_millis: int = 30000):
Expand Down Expand Up @@ -489,7 +489,7 @@ def get_log_emitter(
"""Returns a `LogEmitter` for use within a python process.
This function is a convenience wrapper for
opentelemetry.sdk.logs.LogEmitterProvider.get_log_emitter.
opentelemetry.sdk._logs.LogEmitterProvider.get_log_emitter.
If log_emitter_provider param is omitted the current configured one is used.
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from typing import IO, Callable, Deque, List, Optional, Sequence

from opentelemetry.context import attach, detach, set_value
from opentelemetry.sdk.logs import LogData, LogProcessor, LogRecord
from opentelemetry.sdk._logs import LogData, LogProcessor, LogRecord
from opentelemetry.util._time import _time_ns

_logger = logging.getLogger(__name__)
Expand All @@ -39,7 +39,7 @@ class LogExporter(abc.ABC):
Interface to be implemented by services that want to export logs received
in their own format.
To export data this MUST be registered to the :class`opentelemetry.sdk.logs.LogEmitter` using a
To export data this MUST be registered to the :class`opentelemetry.sdk._logs.LogEmitter` using a
log processor.
"""

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
import threading
import typing

from opentelemetry.sdk.logs import LogData
from opentelemetry.sdk.logs.export import LogExporter, LogExportResult
from opentelemetry.sdk._logs import LogData
from opentelemetry.sdk._logs.export import LogExporter, LogExportResult


class InMemoryLogExporter(LogExporter):
Expand Down
8 changes: 4 additions & 4 deletions opentelemetry-sdk/tests/logs/test_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,21 @@
from unittest.mock import Mock, patch

from opentelemetry.sdk import trace
from opentelemetry.sdk.logs import (
from opentelemetry.sdk._logs import (
LogData,
LogEmitterProvider,
LogRecord,
OTLPHandler,
)
from opentelemetry.sdk.logs.export import (
from opentelemetry.sdk._logs.export import (
BatchLogProcessor,
ConsoleExporter,
SimpleLogProcessor,
)
from opentelemetry.sdk.logs.export.in_memory_log_exporter import (
from opentelemetry.sdk._logs.export.in_memory_log_exporter import (
InMemoryLogExporter,
)
from opentelemetry.sdk.logs.severity import SeverityNumber
from opentelemetry.sdk._logs.severity import SeverityNumber
from opentelemetry.sdk.resources import Resource as SDKResource
from opentelemetry.sdk.util.instrumentation import InstrumentationInfo
from opentelemetry.trace import TraceFlags
Expand Down
22 changes: 11 additions & 11 deletions opentelemetry-sdk/tests/logs/test_global_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,20 @@
from logging import WARNING
from unittest.mock import patch

from opentelemetry.sdk import logs
from opentelemetry.sdk.environment_variables import (
OTEL_PYTHON_LOG_EMITTER_PROVIDER,
)
from opentelemetry.sdk.logs import (
from opentelemetry.sdk import _logs
from opentelemetry.sdk._logs import (
LogEmitterProvider,
get_log_emitter_provider,
set_log_emitter_provider,
)
from opentelemetry.sdk.environment_variables import (
OTEL_PYTHON_LOG_EMITTER_PROVIDER,
)


class TestGlobals(unittest.TestCase):
def tearDown(self):
reload(logs)
reload(_logs)

def check_override_not_allowed(self):
"""set_log_emitter_provider should throw a warning when overridden"""
Expand All @@ -42,34 +42,34 @@ def check_override_not_allowed(self):
test.output,
[
(
"WARNING:opentelemetry.sdk.logs:Overriding of current "
"WARNING:opentelemetry.sdk._logs:Overriding of current "
"LogEmitterProvider is not allowed"
)
],
)
self.assertIs(provider, get_log_emitter_provider())

def test_set_tracer_provider(self):
reload(logs)
reload(_logs)
provider = LogEmitterProvider()
set_log_emitter_provider(provider)
retrieved_provider = get_log_emitter_provider()
self.assertEqual(provider, retrieved_provider)

def test_tracer_provider_override_warning(self):
reload(logs)
reload(_logs)
self.check_override_not_allowed()

@patch.dict(
"os.environ",
{OTEL_PYTHON_LOG_EMITTER_PROVIDER: "sdk_log_emitter_provider"},
)
def test_sdk_log_emitter_provider(self):
reload(logs)
reload(_logs)
self.check_override_not_allowed()

@patch.dict("os.environ", {OTEL_PYTHON_LOG_EMITTER_PROVIDER: "unknown"})
def test_unknown_log_emitter_provider(self):
reload(logs)
reload(_logs)
with self.assertRaises(Exception):
get_log_emitter_provider()
4 changes: 2 additions & 2 deletions opentelemetry-sdk/tests/logs/test_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
from unittest.mock import Mock

from opentelemetry.sdk import trace
from opentelemetry.sdk.logs import LogEmitter, OTLPHandler
from opentelemetry.sdk.logs.severity import SeverityNumber
from opentelemetry.sdk._logs import LogEmitter, OTLPHandler
from opentelemetry.sdk._logs.severity import SeverityNumber
from opentelemetry.trace import INVALID_SPAN_CONTEXT


Expand Down
4 changes: 2 additions & 2 deletions opentelemetry-sdk/tests/logs/test_multi_log_prcessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@
from abc import ABC, abstractmethod
from unittest.mock import Mock

from opentelemetry.sdk.logs import (
from opentelemetry.sdk._logs import (
ConcurrentMultiLogProcessor,
LogEmitterProvider,
LogProcessor,
LogRecord,
OTLPHandler,
SynchronousMultiLogProcessor,
)
from opentelemetry.sdk.logs.severity import SeverityNumber
from opentelemetry.sdk._logs.severity import SeverityNumber


class AnotherLogProcessor(LogProcessor):
Expand Down

0 comments on commit 0cd439f

Please sign in to comment.