microbootstrap 1.5.4__tar.gz → 1.5.5__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {microbootstrap-1.5.4 → microbootstrap-1.5.5}/PKG-INFO +1 -1
- {microbootstrap-1.5.4 → microbootstrap-1.5.5}/microbootstrap/bootstrappers/faststream.py +6 -0
- microbootstrap-1.5.5/microbootstrap/middlewares/faststream.py +66 -0
- {microbootstrap-1.5.4 → microbootstrap-1.5.5}/pyproject.toml +1 -1
- {microbootstrap-1.5.4 → microbootstrap-1.5.5}/pyproject.toml.orig +1 -1
- {microbootstrap-1.5.4 → microbootstrap-1.5.5}/README.md +0 -0
- {microbootstrap-1.5.4 → microbootstrap-1.5.5}/microbootstrap/__init__.py +0 -0
- {microbootstrap-1.5.4 → microbootstrap-1.5.5}/microbootstrap/bootstrappers/__init__.py +0 -0
- {microbootstrap-1.5.4 → microbootstrap-1.5.5}/microbootstrap/bootstrappers/base.py +0 -0
- {microbootstrap-1.5.4 → microbootstrap-1.5.5}/microbootstrap/bootstrappers/fastapi.py +0 -0
- {microbootstrap-1.5.4 → microbootstrap-1.5.5}/microbootstrap/bootstrappers/fastmcp.py +0 -0
- {microbootstrap-1.5.4 → microbootstrap-1.5.5}/microbootstrap/bootstrappers/litestar.py +0 -0
- {microbootstrap-1.5.4 → microbootstrap-1.5.5}/microbootstrap/config/__init__.py +0 -0
- {microbootstrap-1.5.4 → microbootstrap-1.5.5}/microbootstrap/config/fastapi.py +0 -0
- {microbootstrap-1.5.4 → microbootstrap-1.5.5}/microbootstrap/config/fastmcp.py +0 -0
- {microbootstrap-1.5.4 → microbootstrap-1.5.5}/microbootstrap/config/faststream.py +0 -0
- {microbootstrap-1.5.4 → microbootstrap-1.5.5}/microbootstrap/config/litestar.py +0 -0
- {microbootstrap-1.5.4 → microbootstrap-1.5.5}/microbootstrap/console_writer.py +0 -0
- {microbootstrap-1.5.4 → microbootstrap-1.5.5}/microbootstrap/exceptions.py +0 -0
- {microbootstrap-1.5.4 → microbootstrap-1.5.5}/microbootstrap/granian_server.py +0 -0
- {microbootstrap-1.5.4 → microbootstrap-1.5.5}/microbootstrap/helpers.py +0 -0
- {microbootstrap-1.5.4 → microbootstrap-1.5.5}/microbootstrap/instruments/__init__.py +0 -0
- {microbootstrap-1.5.4 → microbootstrap-1.5.5}/microbootstrap/instruments/base.py +0 -0
- {microbootstrap-1.5.4 → microbootstrap-1.5.5}/microbootstrap/instruments/cors_instrument.py +0 -0
- {microbootstrap-1.5.4 → microbootstrap-1.5.5}/microbootstrap/instruments/health_checks_instrument.py +0 -0
- {microbootstrap-1.5.4 → microbootstrap-1.5.5}/microbootstrap/instruments/instrument_box.py +0 -0
- {microbootstrap-1.5.4 → microbootstrap-1.5.5}/microbootstrap/instruments/logging_instrument.py +0 -0
- {microbootstrap-1.5.4 → microbootstrap-1.5.5}/microbootstrap/instruments/opentelemetry_instrument.py +0 -0
- {microbootstrap-1.5.4 → microbootstrap-1.5.5}/microbootstrap/instruments/prometheus_instrument.py +0 -0
- {microbootstrap-1.5.4 → microbootstrap-1.5.5}/microbootstrap/instruments/pyroscope_instrument.py +0 -0
- {microbootstrap-1.5.4 → microbootstrap-1.5.5}/microbootstrap/instruments/sentry_instrument.py +0 -0
- {microbootstrap-1.5.4 → microbootstrap-1.5.5}/microbootstrap/instruments/swagger_instrument.py +0 -0
- {microbootstrap-1.5.4 → microbootstrap-1.5.5}/microbootstrap/instruments_setupper.py +0 -0
- {microbootstrap-1.5.4 → microbootstrap-1.5.5}/microbootstrap/middlewares/__init__.py +0 -0
- {microbootstrap-1.5.4 → microbootstrap-1.5.5}/microbootstrap/middlewares/fastapi.py +0 -0
- {microbootstrap-1.5.4 → microbootstrap-1.5.5}/microbootstrap/middlewares/fastmcp.py +0 -0
- {microbootstrap-1.5.4 → microbootstrap-1.5.5}/microbootstrap/middlewares/litestar.py +0 -0
- {microbootstrap-1.5.4 → microbootstrap-1.5.5}/microbootstrap/py.typed +0 -0
- {microbootstrap-1.5.4 → microbootstrap-1.5.5}/microbootstrap/settings.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: microbootstrap
|
|
3
|
-
Version: 1.5.
|
|
3
|
+
Version: 1.5.5
|
|
4
4
|
Summary: Package for bootstrapping new micro-services
|
|
5
5
|
Keywords: python,microservice,bootstrap,opentelemetry,logging,error-tracing,litestar,fastapi,fastmcp,mcp
|
|
6
6
|
Author: community-of-python
|
|
@@ -24,6 +24,7 @@ from microbootstrap.instruments.opentelemetry_instrument import (
|
|
|
24
24
|
from microbootstrap.instruments.prometheus_instrument import FastStreamPrometheusConfig, PrometheusInstrument
|
|
25
25
|
from microbootstrap.instruments.pyroscope_instrument import PyroscopeInstrument
|
|
26
26
|
from microbootstrap.instruments.sentry_instrument import SentryInstrument
|
|
27
|
+
from microbootstrap.middlewares.faststream import FastStreamOpenTelemetryBaggageMiddleware
|
|
27
28
|
from microbootstrap.settings import FastStreamSettings
|
|
28
29
|
|
|
29
30
|
|
|
@@ -101,6 +102,11 @@ class FastStreamOpentelemetryInstrument(BaseOpentelemetryInstrument[FastStreamOp
|
|
|
101
102
|
application.broker.add_middleware(
|
|
102
103
|
self.instrument_config.opentelemetry_middleware_cls(tracer_provider=self.tracer_provider),
|
|
103
104
|
)
|
|
105
|
+
application.broker.add_middleware(
|
|
106
|
+
FastStreamOpenTelemetryBaggageMiddleware(
|
|
107
|
+
baggage_span_attributes=self.instrument_config.opentelemetry_baggage_span_attributes,
|
|
108
|
+
),
|
|
109
|
+
)
|
|
104
110
|
return application
|
|
105
111
|
|
|
106
112
|
@classmethod
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
import typing
|
|
3
|
+
|
|
4
|
+
from faststream._internal.middlewares import BaseMiddleware
|
|
5
|
+
from opentelemetry import baggage, propagate
|
|
6
|
+
|
|
7
|
+
from microbootstrap.instruments.opentelemetry_instrument import opentelemetry_baggage_scope
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
if typing.TYPE_CHECKING:
|
|
11
|
+
from faststream._internal.basic_types import AsyncFuncAny
|
|
12
|
+
from faststream._internal.context import ContextRepo
|
|
13
|
+
from faststream.message import StreamMessage
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class FastStreamOpenTelemetryBaggageMiddleware:
|
|
17
|
+
def __init__(self, *, baggage_span_attributes: typing.Mapping[str, str]) -> None:
|
|
18
|
+
self.baggage_span_attributes = baggage_span_attributes
|
|
19
|
+
|
|
20
|
+
def __call__(
|
|
21
|
+
self,
|
|
22
|
+
msg: typing.Any, # noqa: ANN401
|
|
23
|
+
/,
|
|
24
|
+
*,
|
|
25
|
+
context: ContextRepo,
|
|
26
|
+
) -> _FastStreamOpenTelemetryBaggageMiddleware:
|
|
27
|
+
return _FastStreamOpenTelemetryBaggageMiddleware(
|
|
28
|
+
msg,
|
|
29
|
+
context=context,
|
|
30
|
+
baggage_span_attributes=self.baggage_span_attributes,
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
class _FastStreamOpenTelemetryBaggageMiddleware(BaseMiddleware[typing.Any, typing.Any]):
|
|
35
|
+
def __init__(
|
|
36
|
+
self,
|
|
37
|
+
msg: typing.Any, # noqa: ANN401
|
|
38
|
+
/,
|
|
39
|
+
*,
|
|
40
|
+
context: ContextRepo,
|
|
41
|
+
baggage_span_attributes: typing.Mapping[str, str],
|
|
42
|
+
) -> None:
|
|
43
|
+
super().__init__(msg, context=context)
|
|
44
|
+
self.baggage_span_attributes = baggage_span_attributes
|
|
45
|
+
|
|
46
|
+
async def consume_scope(
|
|
47
|
+
self,
|
|
48
|
+
call_next: AsyncFuncAny,
|
|
49
|
+
msg: StreamMessage[typing.Any],
|
|
50
|
+
) -> typing.Any: # noqa: ANN401
|
|
51
|
+
extracted_baggage: typing.Final = baggage.get_all(propagate.extract(msg.headers))
|
|
52
|
+
with opentelemetry_baggage_scope(
|
|
53
|
+
extracted_baggage,
|
|
54
|
+
current_span_attributes=self.baggage_span_attributes,
|
|
55
|
+
):
|
|
56
|
+
return await call_next(msg)
|
|
57
|
+
|
|
58
|
+
async def publish_scope(
|
|
59
|
+
self,
|
|
60
|
+
call_next: typing.Callable[[typing.Any], typing.Awaitable[typing.Any]],
|
|
61
|
+
cmd: typing.Any, # noqa: ANN401
|
|
62
|
+
) -> typing.Any: # noqa: ANN401
|
|
63
|
+
for field in propagate.get_global_textmap().fields:
|
|
64
|
+
cmd.headers.pop(field, None)
|
|
65
|
+
propagate.inject(cmd.headers)
|
|
66
|
+
return await call_next(cmd)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{microbootstrap-1.5.4 → microbootstrap-1.5.5}/microbootstrap/instruments/health_checks_instrument.py
RENAMED
|
File without changes
|
|
File without changes
|
{microbootstrap-1.5.4 → microbootstrap-1.5.5}/microbootstrap/instruments/logging_instrument.py
RENAMED
|
File without changes
|
{microbootstrap-1.5.4 → microbootstrap-1.5.5}/microbootstrap/instruments/opentelemetry_instrument.py
RENAMED
|
File without changes
|
{microbootstrap-1.5.4 → microbootstrap-1.5.5}/microbootstrap/instruments/prometheus_instrument.py
RENAMED
|
File without changes
|
{microbootstrap-1.5.4 → microbootstrap-1.5.5}/microbootstrap/instruments/pyroscope_instrument.py
RENAMED
|
File without changes
|
{microbootstrap-1.5.4 → microbootstrap-1.5.5}/microbootstrap/instruments/sentry_instrument.py
RENAMED
|
File without changes
|
{microbootstrap-1.5.4 → microbootstrap-1.5.5}/microbootstrap/instruments/swagger_instrument.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|