Skip to content

Commit a23d5b3

Browse files
authored
Rename Handler and release 1.0.0 (#19)
* rename handler to OtelScoutHandler * delete otelLoggingManager class module * bump version to 1.0.0 * remote deprecated otel logger tests * use x-scout-key as header
1 parent bdbd499 commit a23d5b3

File tree

9 files changed

+22
-117
lines changed

9 files changed

+22
-117
lines changed

README.md

+12-10
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ pip install scout-apm-python-logging
2222

2323
### Using dictConfig
2424

25-
We recommend setting up the `OtelScoutHandler` using Python's [`dictConfig`](https://docs.python.org/3/library/logging.config.html#logging.config.dictConfig). Here's an example configuration:
25+
We recommend setting up the `ScoutOtelHandler` using Python's [`dictConfig`](https://docs.python.org/3/library/logging.config.html#logging.config.dictConfig). Here's an example configuration:
2626

2727
```python
2828
import logging
2929
from logging.config import dictConfig
30-
from scout_apm_python_logging import OtelScoutHandler
30+
from scout_apm_python_logging import ScoutOtelHandler
3131

3232
LOGGING_CONFIG = {
3333
"version": 1,
@@ -40,7 +40,7 @@ LOGGING_CONFIG = {
4040
"handlers": {
4141
"otel": {
4242
"level": "DEBUG",
43-
"class": "scout_apm_python_logging.OtelScoutHandler",
43+
"class": "scout_apm_python_logging.ScoutOtelHandler",
4444
"service_name": "your-service-name",
4545
},
4646
"console": {
@@ -63,33 +63,35 @@ dictConfig(LOGGING_CONFIG)
6363

6464
### Adding to an Existing Logger
6565

66-
You can also add the `OtelScoutHandler` to an existing logger:
66+
You can also add the `ScoutOtelHandler` to an existing logger:
6767

6868
```python
6969
import logging
70-
from scout_apm_python_logging import OtelScoutHandler
70+
from scout_apm_python_logging import ScoutOtelHandler
7171

7272
# Get your logger
7373
logger = logging.getLogger(__name__)
7474

75-
# Create and add the OtelScoutHandler
76-
handler = OtelScoutHandler(service_name="your-service-name")
75+
# Create and add the ScoutOtelHandler
76+
handler = ScoutOtelHandler(service_name="your-service-name")
7777
logger.addHandler(handler)
7878
```
7979

80+
> Alternative logging configurations are covered in our [documentation](/https://scoutapm.com/docs/features/log-management#common-configurations-python)
81+
8082
## Configuration
8183

82-
The `OtelScoutHandler` only requires `service_name` to be supplied to the handler as an argument:
84+
The `ScoutOtelHandler` only requires `service_name` to be supplied to the handler as an argument:
8385

8486
If the `scout-apm` is [configured](https://scoutapm.com/docs/python#some-configuration-required) (You've set your `SCOUT_KEY`, etc), you'll only need add your `SCOUT_LOGS_INGEST_KEY` to whichever configuration you are already using. This can also be set as an environment variable.
8587

86-
Make sure to set the `SCOUT_LOGS_INGEST_KEY` variable before running your application.
88+
Make sure to set the `SCOUT_LOGS_INGEST_KEY` variable in the above configuration before running your application.
8789

8890
## OpenTelemetry
8991

9092
The Scout APM Python Logging Agent leverages [OpenTelemetry Python](https://github.com/open-telemetry/opentelemetry-python) to provide powerful and standardized logging capabilities. OpenTelemetry is an observability framework for cloud-native software, offering a collection of tools, APIs, and SDKs for generating, collecting, and exporting telemetry data (metrics, logs, and traces).
9193

92-
Our `OtelScoutHandler` utilizes the OpenTelemetry Python SDK to:
94+
Our `ScoutOtelHandler` utilizes the OpenTelemetry Python SDK to:
9395

9496
1. Create a `LoggerProvider` with a custom resource that includes your service name and instance ID.
9597
2. Set up an OTLP (OpenTelemetry Protocol) exporter configured to send logs to Scout's ingestion endpoint.

examples/dictConfig.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"handlers": {
1818
"otel": {
1919
"level": "DEBUG",
20-
"class": "scout_apm_logging.OtelScoutHandler",
20+
"class": "scout_apm_logging.ScoutOtelHandler",
2121
"service_name": "example-python-app",
2222
},
2323
"console": {

examples/flask_app.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"handlers": {
1818
"otel": {
1919
"level": "DEBUG",
20-
"class": "scout_apm_logging.OtelScoutHandler",
20+
"class": "scout_apm_logging.ScoutOtelHandler",
2121
"service_name": "example-python-app",
2222
},
2323
"console": {

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "scout-apm-logging"
3-
version = "0.1.2"
3+
version = "1.0.0"
44
description = "Scout APM Python Logging Agent"
55
authors = ["Quinn Milionis <[email protected]>"]
66
readme = "README.md"

scout_apm_logging/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
from scout_apm_logging.handler import OtelScoutHandler
1+
from scout_apm_logging.handler import ScoutOtelHandler

scout_apm_logging/handler.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from scout_apm_logging.utils.operation_utils import get_operation_detail
1212

1313

14-
class OtelScoutHandler(logging.Handler):
14+
class ScoutOtelHandler(logging.Handler):
1515
def __init__(self, service_name):
1616
super().__init__()
1717
self.logger_provider = None
@@ -33,7 +33,7 @@ def setup_logging(self):
3333
_logs.set_logger_provider(self.logger_provider)
3434

3535
otlp_exporter = OTLPLogExporter(
36-
headers={"x-telemetryhub-key": self.ingest_key},
36+
headers={"x-scout-key": self.ingest_key},
3737
endpoint=self.endpoint,
3838
)
3939
self.logger_provider.add_log_record_processor(
@@ -87,7 +87,7 @@ def emit(self, record):
8787

8888
self.otel_handler.emit(record)
8989
except Exception as e:
90-
print(f"Error in OtelScoutHandler.emit: {e}")
90+
print(f"Error in ScoutOtelHandler.emit: {e}")
9191
finally:
9292
self._handling_log.value = False
9393

scout_apm_logging/otel_logger.py

-48
This file was deleted.

tests/unit/test_handler.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import logging
33
import io
44
from unittest.mock import patch, MagicMock
5-
from scout_apm_logging.handler import OtelScoutHandler
5+
from scout_apm_logging.handler import ScoutOtelHandler
66
from scout_apm.core.tracked_request import Span
77

88

@@ -13,7 +13,7 @@ def otel_scout_handler():
1313
), patch("scout_apm_logging.handler.BatchLogRecordProcessor"), patch(
1414
"scout_apm_logging.handler.Resource"
1515
):
16-
handler = OtelScoutHandler(service_name="test-service")
16+
handler = ScoutOtelHandler(service_name="test-service")
1717
yield handler
1818

1919

@@ -155,7 +155,7 @@ def test_emit_exception_handling(otel_scout_handler):
155155

156156
# Check that the exception was caught and the error message was printed
157157
assert (
158-
"Error in OtelScoutHandler.emit: Test exception" in mock_stdout.getvalue()
158+
"Error in ScoutOtelHandler.emit: Test exception" in mock_stdout.getvalue()
159159
)
160160

161161
otel_scout_handler._handling_log.value = False

tests/unit/test_otel_logger.py

-49
This file was deleted.

0 commit comments

Comments
 (0)