Skip to content

Commit

Permalink
Merge branch 'main' into refactor_rabbit_queue
Browse files Browse the repository at this point in the history
  • Loading branch information
pepellsd authored Dec 21, 2024
2 parents 10df170 + 2ba3eed commit 8c0972f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 22 deletions.
21 changes: 0 additions & 21 deletions docs/docs/en/getting-started/logging.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@ search:

# Application and Access Logging

**FastStream** uses two already configured loggers:

* `faststream` - used by `FastStream` app
* `faststream.access` - used by the broker

## Logging Requests

To log requests, it is strongly recommended to use the `access_logger` of your broker, as it is available from the [Context](../getting-started/context/existed.md){.internal-link} of your application.
Expand Down Expand Up @@ -77,22 +72,6 @@ from faststream.rabbit import RabbitBroker
broker = RabbitBroker(log_fmt="%(asctime)s %(levelname)s - %(message)s")
```

## Logger Access

If you want to override default logger's behavior, you can access them directly via `logging`.

```python
import logging
logger = logging.getLogger("faststream")
access_logger = logging.getLogger("faststream.access")
```

Or you can import them from **FastStream**.

```python
from faststream.log import access_logger, logger
```

## Using Your Own Loggers

Since **FastStream** works with the standard `logging.Logger` object, you can initiate an application and a broker
Expand Down
5 changes: 5 additions & 0 deletions faststream/opentelemetry/consts.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
from faststream.__about__ import __version__


class MessageAction:
CREATE = "create"
PUBLISH = "publish"
Expand All @@ -9,3 +12,5 @@ class MessageAction:
ERROR_TYPE = "error.type"
MESSAGING_DESTINATION_PUBLISH_NAME = "messaging.destination_publish.name"
WITH_BATCH = "with_batch"
INSTRUMENTING_MODULE_NAME = "opentelemetry.instrumentation.faststream"
INSTRUMENTING_LIBRARY_VERSION = __version__
5 changes: 4 additions & 1 deletion faststream/opentelemetry/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
from faststream.opentelemetry.baggage import Baggage
from faststream.opentelemetry.consts import (
ERROR_TYPE,
INSTRUMENTING_LIBRARY_VERSION,
INSTRUMENTING_MODULE_NAME,
MESSAGING_DESTINATION_PUBLISH_NAME,
OTEL_SCHEMA,
WITH_BATCH,
Expand Down Expand Up @@ -330,7 +332,8 @@ def _get_meter(

def _get_tracer(tracer_provider: Optional["TracerProvider"] = None) -> "Tracer":
return trace.get_tracer(
__name__,
instrumenting_module_name=INSTRUMENTING_MODULE_NAME,
instrumenting_library_version=INSTRUMENTING_LIBRARY_VERSION,
tracer_provider=tracer_provider,
schema_url=OTEL_SCHEMA,
)
Expand Down

0 comments on commit 8c0972f

Please sign in to comment.