jararaca 0.3.27__tar.gz → 0.3.28__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.
Potentially problematic release.
This version of jararaca might be problematic. Click here for more details.
- {jararaca-0.3.27 → jararaca-0.3.28}/PKG-INFO +1 -1
- {jararaca-0.3.27 → jararaca-0.3.28}/pyproject.toml +1 -1
- {jararaca-0.3.27 → jararaca-0.3.28}/src/jararaca/__init__.py +9 -0
- jararaca-0.3.28/src/jararaca/observability/constants.py +3 -0
- jararaca-0.3.28/src/jararaca/observability/fastapi_exception_handler.py +33 -0
- {jararaca-0.3.27 → jararaca-0.3.28}/src/jararaca/observability/providers/otel.py +10 -15
- {jararaca-0.3.27 → jararaca-0.3.28}/LICENSE +0 -0
- {jararaca-0.3.27 → jararaca-0.3.28}/README.md +0 -0
- {jararaca-0.3.27 → jararaca-0.3.28}/docs/CNAME +0 -0
- {jararaca-0.3.27 → jararaca-0.3.28}/docs/architecture.md +0 -0
- {jararaca-0.3.27 → jararaca-0.3.28}/docs/assets/_f04774c9-7e05-4da4-8b17-8be23f6a1475.jpeg +0 -0
- {jararaca-0.3.27 → jararaca-0.3.28}/docs/assets/_f04774c9-7e05-4da4-8b17-8be23f6a1475.webp +0 -0
- {jararaca-0.3.27 → jararaca-0.3.28}/docs/assets/tracing_example.png +0 -0
- {jararaca-0.3.27 → jararaca-0.3.28}/docs/expose-type.md +0 -0
- {jararaca-0.3.27 → jararaca-0.3.28}/docs/http-rpc.md +0 -0
- {jararaca-0.3.27 → jararaca-0.3.28}/docs/index.md +0 -0
- {jararaca-0.3.27 → jararaca-0.3.28}/docs/interceptors.md +0 -0
- {jararaca-0.3.27 → jararaca-0.3.28}/docs/messagebus.md +0 -0
- {jararaca-0.3.27 → jararaca-0.3.28}/docs/retry.md +0 -0
- {jararaca-0.3.27 → jararaca-0.3.28}/docs/scheduler.md +0 -0
- {jararaca-0.3.27 → jararaca-0.3.28}/docs/stylesheets/custom.css +0 -0
- {jararaca-0.3.27 → jararaca-0.3.28}/docs/websocket.md +0 -0
- {jararaca-0.3.27 → jararaca-0.3.28}/src/jararaca/__main__.py +0 -0
- {jararaca-0.3.27 → jararaca-0.3.28}/src/jararaca/broker_backend/__init__.py +0 -0
- {jararaca-0.3.27 → jararaca-0.3.28}/src/jararaca/broker_backend/mapper.py +0 -0
- {jararaca-0.3.27 → jararaca-0.3.28}/src/jararaca/broker_backend/redis_broker_backend.py +0 -0
- {jararaca-0.3.27 → jararaca-0.3.28}/src/jararaca/cli.py +0 -0
- {jararaca-0.3.27 → jararaca-0.3.28}/src/jararaca/common/__init__.py +0 -0
- {jararaca-0.3.27 → jararaca-0.3.28}/src/jararaca/core/__init__.py +0 -0
- {jararaca-0.3.27 → jararaca-0.3.28}/src/jararaca/core/providers.py +0 -0
- {jararaca-0.3.27 → jararaca-0.3.28}/src/jararaca/core/uow.py +0 -0
- {jararaca-0.3.27 → jararaca-0.3.28}/src/jararaca/di.py +0 -0
- {jararaca-0.3.27 → jararaca-0.3.28}/src/jararaca/files/entity.py.mako +0 -0
- {jararaca-0.3.27 → jararaca-0.3.28}/src/jararaca/lifecycle.py +0 -0
- {jararaca-0.3.27 → jararaca-0.3.28}/src/jararaca/messagebus/__init__.py +0 -0
- {jararaca-0.3.27 → jararaca-0.3.28}/src/jararaca/messagebus/bus_message_controller.py +0 -0
- {jararaca-0.3.27 → jararaca-0.3.28}/src/jararaca/messagebus/consumers/__init__.py +0 -0
- {jararaca-0.3.27 → jararaca-0.3.28}/src/jararaca/messagebus/decorators.py +0 -0
- {jararaca-0.3.27 → jararaca-0.3.28}/src/jararaca/messagebus/implicit_headers.py +0 -0
- {jararaca-0.3.27 → jararaca-0.3.28}/src/jararaca/messagebus/interceptors/__init__.py +0 -0
- {jararaca-0.3.27 → jararaca-0.3.28}/src/jararaca/messagebus/interceptors/aiopika_publisher_interceptor.py +0 -0
- {jararaca-0.3.27 → jararaca-0.3.28}/src/jararaca/messagebus/interceptors/publisher_interceptor.py +0 -0
- {jararaca-0.3.27 → jararaca-0.3.28}/src/jararaca/messagebus/message.py +0 -0
- {jararaca-0.3.27 → jararaca-0.3.28}/src/jararaca/messagebus/publisher.py +0 -0
- {jararaca-0.3.27 → jararaca-0.3.28}/src/jararaca/messagebus/worker.py +0 -0
- {jararaca-0.3.27 → jararaca-0.3.28}/src/jararaca/microservice.py +0 -0
- {jararaca-0.3.27 → jararaca-0.3.28}/src/jararaca/observability/decorators.py +0 -0
- {jararaca-0.3.27 → jararaca-0.3.28}/src/jararaca/observability/hooks.py +0 -0
- {jararaca-0.3.27 → jararaca-0.3.28}/src/jararaca/observability/interceptor.py +0 -0
- {jararaca-0.3.27 → jararaca-0.3.28}/src/jararaca/observability/providers/__init__.py +0 -0
- {jararaca-0.3.27 → jararaca-0.3.28}/src/jararaca/persistence/base.py +0 -0
- {jararaca-0.3.27 → jararaca-0.3.28}/src/jararaca/persistence/exports.py +0 -0
- {jararaca-0.3.27 → jararaca-0.3.28}/src/jararaca/persistence/interceptors/__init__.py +0 -0
- {jararaca-0.3.27 → jararaca-0.3.28}/src/jararaca/persistence/interceptors/aiosqa_interceptor.py +0 -0
- {jararaca-0.3.27 → jararaca-0.3.28}/src/jararaca/persistence/interceptors/constants.py +0 -0
- {jararaca-0.3.27 → jararaca-0.3.28}/src/jararaca/persistence/interceptors/decorators.py +0 -0
- {jararaca-0.3.27 → jararaca-0.3.28}/src/jararaca/persistence/session.py +0 -0
- {jararaca-0.3.27 → jararaca-0.3.28}/src/jararaca/persistence/sort_filter.py +0 -0
- {jararaca-0.3.27 → jararaca-0.3.28}/src/jararaca/persistence/utilities.py +0 -0
- {jararaca-0.3.27 → jararaca-0.3.28}/src/jararaca/presentation/__init__.py +0 -0
- {jararaca-0.3.27 → jararaca-0.3.28}/src/jararaca/presentation/decorators.py +0 -0
- {jararaca-0.3.27 → jararaca-0.3.28}/src/jararaca/presentation/hooks.py +0 -0
- {jararaca-0.3.27 → jararaca-0.3.28}/src/jararaca/presentation/http_microservice.py +0 -0
- {jararaca-0.3.27 → jararaca-0.3.28}/src/jararaca/presentation/server.py +0 -0
- {jararaca-0.3.27 → jararaca-0.3.28}/src/jararaca/presentation/websocket/__init__.py +0 -0
- {jararaca-0.3.27 → jararaca-0.3.28}/src/jararaca/presentation/websocket/base_types.py +0 -0
- {jararaca-0.3.27 → jararaca-0.3.28}/src/jararaca/presentation/websocket/context.py +0 -0
- {jararaca-0.3.27 → jararaca-0.3.28}/src/jararaca/presentation/websocket/decorators.py +0 -0
- {jararaca-0.3.27 → jararaca-0.3.28}/src/jararaca/presentation/websocket/redis.py +0 -0
- {jararaca-0.3.27 → jararaca-0.3.28}/src/jararaca/presentation/websocket/types.py +0 -0
- {jararaca-0.3.27 → jararaca-0.3.28}/src/jararaca/presentation/websocket/websocket_interceptor.py +0 -0
- {jararaca-0.3.27 → jararaca-0.3.28}/src/jararaca/py.typed +0 -0
- {jararaca-0.3.27 → jararaca-0.3.28}/src/jararaca/reflect/__init__.py +0 -0
- {jararaca-0.3.27 → jararaca-0.3.28}/src/jararaca/reflect/controller_inspect.py +0 -0
- {jararaca-0.3.27 → jararaca-0.3.28}/src/jararaca/reflect/metadata.py +0 -0
- {jararaca-0.3.27 → jararaca-0.3.28}/src/jararaca/rpc/__init__.py +0 -0
- {jararaca-0.3.27 → jararaca-0.3.28}/src/jararaca/rpc/http/__init__.py +0 -0
- {jararaca-0.3.27 → jararaca-0.3.28}/src/jararaca/rpc/http/backends/__init__.py +0 -0
- {jararaca-0.3.27 → jararaca-0.3.28}/src/jararaca/rpc/http/backends/httpx.py +0 -0
- {jararaca-0.3.27 → jararaca-0.3.28}/src/jararaca/rpc/http/backends/otel.py +0 -0
- {jararaca-0.3.27 → jararaca-0.3.28}/src/jararaca/rpc/http/decorators.py +0 -0
- {jararaca-0.3.27 → jararaca-0.3.28}/src/jararaca/rpc/http/httpx.py +0 -0
- {jararaca-0.3.27 → jararaca-0.3.28}/src/jararaca/scheduler/__init__.py +0 -0
- {jararaca-0.3.27 → jararaca-0.3.28}/src/jararaca/scheduler/beat_worker.py +0 -0
- {jararaca-0.3.27 → jararaca-0.3.28}/src/jararaca/scheduler/decorators.py +0 -0
- {jararaca-0.3.27 → jararaca-0.3.28}/src/jararaca/scheduler/types.py +0 -0
- {jararaca-0.3.27 → jararaca-0.3.28}/src/jararaca/tools/app_config/__init__.py +0 -0
- {jararaca-0.3.27 → jararaca-0.3.28}/src/jararaca/tools/app_config/decorators.py +0 -0
- {jararaca-0.3.27 → jararaca-0.3.28}/src/jararaca/tools/app_config/interceptor.py +0 -0
- {jararaca-0.3.27 → jararaca-0.3.28}/src/jararaca/tools/typescript/__init__.py +0 -0
- {jararaca-0.3.27 → jararaca-0.3.28}/src/jararaca/tools/typescript/decorators.py +0 -0
- {jararaca-0.3.27 → jararaca-0.3.28}/src/jararaca/tools/typescript/interface_parser.py +0 -0
- {jararaca-0.3.27 → jararaca-0.3.28}/src/jararaca/utils/__init__.py +0 -0
- {jararaca-0.3.27 → jararaca-0.3.28}/src/jararaca/utils/rabbitmq_utils.py +0 -0
- {jararaca-0.3.27 → jararaca-0.3.28}/src/jararaca/utils/retry.py +0 -0
|
@@ -18,6 +18,9 @@ if TYPE_CHECKING:
|
|
|
18
18
|
use_app_type,
|
|
19
19
|
)
|
|
20
20
|
from jararaca.observability.decorators import TracedClass, TracedFunc, traced_class
|
|
21
|
+
from jararaca.observability.fastapi_exception_handler import (
|
|
22
|
+
setup_fastapi_exception_handler,
|
|
23
|
+
)
|
|
21
24
|
from jararaca.observability.hooks import (
|
|
22
25
|
add_event,
|
|
23
26
|
get_tracing_provider,
|
|
@@ -239,6 +242,7 @@ if TYPE_CHECKING:
|
|
|
239
242
|
"spawn_trace",
|
|
240
243
|
"set_span_attribute",
|
|
241
244
|
"add_event",
|
|
245
|
+
"setup_fastapi_exception_handler",
|
|
242
246
|
"set_span_status",
|
|
243
247
|
"record_exception",
|
|
244
248
|
"get_tracing_provider",
|
|
@@ -416,6 +420,11 @@ _dynamic_imports: "dict[str, tuple[str, str, str | None]]" = {
|
|
|
416
420
|
"TracedClass": (__SPEC_PARENT__, "observability.decorators", None),
|
|
417
421
|
"traced_class": (__SPEC_PARENT__, "observability.decorators", None),
|
|
418
422
|
"spawn_trace": (__SPEC_PARENT__, "observability.hooks", None),
|
|
423
|
+
"setup_fastapi_exception_handler": (
|
|
424
|
+
__SPEC_PARENT__,
|
|
425
|
+
"observability.fastapi_exception_handler",
|
|
426
|
+
None,
|
|
427
|
+
),
|
|
419
428
|
"set_span_attribute": (__SPEC_PARENT__, "observability.hooks", None),
|
|
420
429
|
"start_span": (__SPEC_PARENT__, "observability.hooks", None),
|
|
421
430
|
"add_event": (__SPEC_PARENT__, "observability.hooks", None),
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
from fastapi import FastAPI, Request, Response
|
|
2
|
+
from fastapi.exception_handlers import (
|
|
3
|
+
http_exception_handler,
|
|
4
|
+
request_validation_exception_handler,
|
|
5
|
+
)
|
|
6
|
+
from fastapi.exceptions import RequestValidationError
|
|
7
|
+
from fastapi.responses import JSONResponse
|
|
8
|
+
from starlette.exceptions import HTTPException
|
|
9
|
+
|
|
10
|
+
from jararaca.observability.constants import TRACEPARENT_KEY
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def setup_fastapi_exception_handler(
|
|
14
|
+
app: FastAPI, trace_header_name: str = "traceparent"
|
|
15
|
+
) -> None:
|
|
16
|
+
async def base_http_exception_handler(
|
|
17
|
+
request: Request, exc: HTTPException | RequestValidationError
|
|
18
|
+
) -> JSONResponse | Response:
|
|
19
|
+
|
|
20
|
+
if isinstance(exc, RequestValidationError):
|
|
21
|
+
response = await request_validation_exception_handler(request, exc)
|
|
22
|
+
response.headers[trace_header_name] = request.scope.get(TRACEPARENT_KEY, "")
|
|
23
|
+
return response
|
|
24
|
+
else:
|
|
25
|
+
err_response = await http_exception_handler(request, exc)
|
|
26
|
+
|
|
27
|
+
err_response.headers[trace_header_name] = request.scope.get(
|
|
28
|
+
TRACEPARENT_KEY, ""
|
|
29
|
+
)
|
|
30
|
+
return err_response
|
|
31
|
+
|
|
32
|
+
app.exception_handlers[HTTPException] = base_http_exception_handler
|
|
33
|
+
app.exception_handlers[RequestValidationError] = base_http_exception_handler
|
|
@@ -2,7 +2,6 @@ import logging
|
|
|
2
2
|
from contextlib import asynccontextmanager, contextmanager
|
|
3
3
|
from typing import Any, AsyncGenerator, Generator, Literal, Protocol
|
|
4
4
|
|
|
5
|
-
from fastapi import HTTPException
|
|
6
5
|
from opentelemetry import metrics, trace
|
|
7
6
|
from opentelemetry._logs import set_logger_provider
|
|
8
7
|
from opentelemetry.baggage.propagation import W3CBaggagePropagator
|
|
@@ -35,6 +34,7 @@ from jararaca.microservice import (
|
|
|
35
34
|
Microservice,
|
|
36
35
|
use_app_transaction_context,
|
|
37
36
|
)
|
|
37
|
+
from jararaca.observability.constants import TRACEPARENT_KEY
|
|
38
38
|
from jararaca.observability.decorators import (
|
|
39
39
|
AttributeMap,
|
|
40
40
|
AttributeValue,
|
|
@@ -195,25 +195,20 @@ class OtelTracingContextProviderFactory(TracingContextProviderFactory):
|
|
|
195
195
|
},
|
|
196
196
|
) as root_span:
|
|
197
197
|
cx = root_span.get_span_context()
|
|
198
|
+
span_traceparent_id = hex(cx.trace_id)[2:].rjust(32, "0")
|
|
198
199
|
if app_tx_ctx.transaction_data.context_type == "http":
|
|
199
|
-
app_tx_ctx.transaction_data.
|
|
200
|
-
|
|
201
|
-
)
|
|
200
|
+
app_tx_ctx.transaction_data.request.scope[TRACEPARENT_KEY] = (
|
|
201
|
+
span_traceparent_id
|
|
202
|
+
)
|
|
203
|
+
elif app_tx_ctx.transaction_data.context_type == "websocket":
|
|
204
|
+
app_tx_ctx.transaction_data.websocket.scope[TRACEPARENT_KEY] = (
|
|
205
|
+
span_traceparent_id
|
|
206
|
+
)
|
|
202
207
|
tracing_headers: ImplicitHeaders = {}
|
|
203
208
|
TraceContextTextMapPropagator().inject(tracing_headers)
|
|
204
209
|
W3CBaggagePropagator().inject(tracing_headers)
|
|
205
210
|
with provide_implicit_headers(tracing_headers):
|
|
206
|
-
|
|
207
|
-
yield
|
|
208
|
-
except HTTPException as http_exc:
|
|
209
|
-
root_span.record_exception(http_exc)
|
|
210
|
-
root_span.set_status(
|
|
211
|
-
trace.Status(
|
|
212
|
-
trace.StatusCode.ERROR,
|
|
213
|
-
f"HTTP {http_exc.status_code}: {http_exc.detail}",
|
|
214
|
-
)
|
|
215
|
-
)
|
|
216
|
-
raise
|
|
211
|
+
yield
|
|
217
212
|
|
|
218
213
|
|
|
219
214
|
class LoggerHandlerCallback(Protocol):
|
|
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
|
|
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
|
{jararaca-0.3.27 → jararaca-0.3.28}/src/jararaca/messagebus/interceptors/publisher_interceptor.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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{jararaca-0.3.27 → jararaca-0.3.28}/src/jararaca/persistence/interceptors/aiosqa_interceptor.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
|
|
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
|
{jararaca-0.3.27 → jararaca-0.3.28}/src/jararaca/presentation/websocket/websocket_interceptor.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
|
|
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
|