diff --git a/README.md b/README.md index a9b71fd..1b4f33c 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,11 @@ In case the logs failed to be sent to Logz.io after a couple of tries, they will pip install logzio-python-handler ``` +If you'd like to use [Trace context](https://github.com/logzio/logzio-python-handler#trace-context) then you need to install the OpenTelemetry logging instrumentation dependecy by running the following command: + +```bash +pip install logzio-python-handler[opentelemetry-logging] +``` ## Tested Python Versions Travis CI will build this handler and test against: - "3.5" @@ -33,6 +38,8 @@ Travis CI will build this handler and test against: - "3.7" - "3.8" - "3.9" + - "3.10" + - "3.11" We can't ensure compatibility to any other version, as we can't test it automatically. @@ -216,6 +223,12 @@ LOGGING = { If you're sending traces with OpenTelemetry instrumentation (auto or manual), you can correlate your logs with the trace context. That way, your logs will have traces data in it, such as service name, span id and trace id. + +Make sure to install the OpenTelemetry logging instrumentation dependecy by running the following command: + +```bash +pip install logzio-python-handler[opentelemetry-logging] +``` To enable this feature, set the `add_context` param in your handler configuration to `True`, like in this example: ```python diff --git a/logzio/handler.py b/logzio/handler.py index 53f7ea4..988b93d 100644 --- a/logzio/handler.py +++ b/logzio/handler.py @@ -34,7 +34,10 @@ class LogzioHandler(logging.Handler): from opentelemetry.instrumentation.logging import LoggingInstrumentor LoggingInstrumentor().instrument(set_logging_format=True) except ImportError: - print("Can't add trace context. OpenTelemetry logging optional package isn't installed.\nPlease install the following:\npip install 'logzio-python-handler[opentelemetry-logging]'") + print("""Can't add trace context. +OpenTelemetry logging optional package isn't installed. +Please install the following package: +pip install 'logzio-python-handler[opentelemetry-logging]'""") self.logzio_sender = LogzioSender( token=token, url=url, diff --git a/logzio/sender.py b/logzio/sender.py index 5a7d16c..999b729 100644 --- a/logzio/sender.py +++ b/logzio/sender.py @@ -9,7 +9,6 @@ from threading import Thread, enumerate import requests -from .logger import get_logger from .logger import get_stdout_logger if sys.version[0] == '2': diff --git a/requirements.txt b/requirements.txt index 1c39753..9ce9e6f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,3 @@ requests>=2.27.0 protobuf>=3.20.2 -setuptools>=65.5.1 # not directly required, pinned by Snyk to avoid a vulnerability \ No newline at end of file +setuptools>=68.0.0 # not directly required, pinned by Snyk to avoid a vulnerability \ No newline at end of file