microbootstrap 1.2.4__tar.gz → 1.3.0__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.
Files changed (34) hide show
  1. {microbootstrap-1.2.4 → microbootstrap-1.3.0}/PKG-INFO +1 -1
  2. {microbootstrap-1.2.4 → microbootstrap-1.3.0}/microbootstrap/instruments/logging_instrument.py +9 -2
  3. {microbootstrap-1.2.4 → microbootstrap-1.3.0}/microbootstrap/instruments/opentelemetry_instrument.py +4 -8
  4. {microbootstrap-1.2.4 → microbootstrap-1.3.0}/pyproject.toml +1 -1
  5. {microbootstrap-1.2.4 → microbootstrap-1.3.0}/README.md +0 -0
  6. {microbootstrap-1.2.4 → microbootstrap-1.3.0}/microbootstrap/__init__.py +0 -0
  7. {microbootstrap-1.2.4 → microbootstrap-1.3.0}/microbootstrap/bootstrappers/__init__.py +0 -0
  8. {microbootstrap-1.2.4 → microbootstrap-1.3.0}/microbootstrap/bootstrappers/base.py +0 -0
  9. {microbootstrap-1.2.4 → microbootstrap-1.3.0}/microbootstrap/bootstrappers/fastapi.py +0 -0
  10. {microbootstrap-1.2.4 → microbootstrap-1.3.0}/microbootstrap/bootstrappers/faststream.py +0 -0
  11. {microbootstrap-1.2.4 → microbootstrap-1.3.0}/microbootstrap/bootstrappers/litestar.py +0 -0
  12. {microbootstrap-1.2.4 → microbootstrap-1.3.0}/microbootstrap/config/__init__.py +0 -0
  13. {microbootstrap-1.2.4 → microbootstrap-1.3.0}/microbootstrap/config/fastapi.py +0 -0
  14. {microbootstrap-1.2.4 → microbootstrap-1.3.0}/microbootstrap/config/faststream.py +0 -0
  15. {microbootstrap-1.2.4 → microbootstrap-1.3.0}/microbootstrap/config/litestar.py +0 -0
  16. {microbootstrap-1.2.4 → microbootstrap-1.3.0}/microbootstrap/console_writer.py +0 -0
  17. {microbootstrap-1.2.4 → microbootstrap-1.3.0}/microbootstrap/exceptions.py +0 -0
  18. {microbootstrap-1.2.4 → microbootstrap-1.3.0}/microbootstrap/granian_server.py +0 -0
  19. {microbootstrap-1.2.4 → microbootstrap-1.3.0}/microbootstrap/helpers.py +0 -0
  20. {microbootstrap-1.2.4 → microbootstrap-1.3.0}/microbootstrap/instruments/__init__.py +0 -0
  21. {microbootstrap-1.2.4 → microbootstrap-1.3.0}/microbootstrap/instruments/base.py +0 -0
  22. {microbootstrap-1.2.4 → microbootstrap-1.3.0}/microbootstrap/instruments/cors_instrument.py +0 -0
  23. {microbootstrap-1.2.4 → microbootstrap-1.3.0}/microbootstrap/instruments/health_checks_instrument.py +0 -0
  24. {microbootstrap-1.2.4 → microbootstrap-1.3.0}/microbootstrap/instruments/instrument_box.py +0 -0
  25. {microbootstrap-1.2.4 → microbootstrap-1.3.0}/microbootstrap/instruments/prometheus_instrument.py +0 -0
  26. {microbootstrap-1.2.4 → microbootstrap-1.3.0}/microbootstrap/instruments/pyroscope_instrument.py +0 -0
  27. {microbootstrap-1.2.4 → microbootstrap-1.3.0}/microbootstrap/instruments/sentry_instrument.py +0 -0
  28. {microbootstrap-1.2.4 → microbootstrap-1.3.0}/microbootstrap/instruments/swagger_instrument.py +0 -0
  29. {microbootstrap-1.2.4 → microbootstrap-1.3.0}/microbootstrap/instruments_setupper.py +0 -0
  30. {microbootstrap-1.2.4 → microbootstrap-1.3.0}/microbootstrap/middlewares/__init__.py +0 -0
  31. {microbootstrap-1.2.4 → microbootstrap-1.3.0}/microbootstrap/middlewares/fastapi.py +0 -0
  32. {microbootstrap-1.2.4 → microbootstrap-1.3.0}/microbootstrap/middlewares/litestar.py +0 -0
  33. {microbootstrap-1.2.4 → microbootstrap-1.3.0}/microbootstrap/py.typed +0 -0
  34. {microbootstrap-1.2.4 → microbootstrap-1.3.0}/microbootstrap/settings.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: microbootstrap
3
- Version: 1.2.4
3
+ Version: 1.3.0
4
4
  Summary: Package for bootstrapping new micro-services
5
5
  Keywords: python,microservice,bootstrap,opentelemetry,logging,error-tracing,litestar,fastapi
6
6
  Author: community-of-python
@@ -78,7 +78,6 @@ STRUCTLOG_PRE_CHAIN_PROCESSORS: typing.Final[list[typing.Any]] = [
78
78
  structlog.stdlib.add_logger_name,
79
79
  tracer_injection,
80
80
  structlog.stdlib.PositionalArgumentsFormatter(),
81
- structlog.processors.TimeStamper(fmt="%Y-%m-%d %H:%M:%S"),
82
81
  structlog.processors.StackInfoRenderer(),
83
82
  structlog.processors.format_exc_info,
84
83
  structlog.processors.UnicodeDecoder(),
@@ -149,6 +148,9 @@ class LoggingConfig(BaseInstrumentConfig):
149
148
  )
150
149
  logging_exclude_endpoints: list[str] = pydantic.Field(default_factory=lambda: ["/health/", "/metrics"])
151
150
  logging_turn_off_middleware: bool = False
151
+ logging_timestamper_extra_params: dict[str, typing.Any] = pydantic.Field(
152
+ default_factory=lambda: {"fmt": "%Y-%m-%d %H:%M:%S"}
153
+ )
152
154
 
153
155
  @pydantic.model_validator(mode="after")
154
156
  def remove_trailing_slashes_from_logging_exclude_endpoints(self) -> typing_extensions.Self:
@@ -172,6 +174,10 @@ class LoggingInstrument(Instrument[LoggingConfig]):
172
174
  for unset_handlers_logger in self.instrument_config.logging_unset_handlers:
173
175
  logging.getLogger(unset_handlers_logger).handlers = []
174
176
 
177
+ @property
178
+ def _timestamper_processor(self) -> structlog.processors.TimeStamper:
179
+ return structlog.processors.TimeStamper(**self.instrument_config.logging_timestamper_extra_params)
180
+
175
181
  def _configure_structlog_loggers(self) -> None:
176
182
  if self.instrument_config.service_debug:
177
183
  structlog.configure(
@@ -186,6 +192,7 @@ class LoggingInstrument(Instrument[LoggingConfig]):
186
192
  processors=[
187
193
  structlog.stdlib.filter_by_level,
188
194
  *STRUCTLOG_PRE_CHAIN_PROCESSORS,
195
+ self._timestamper_processor,
189
196
  *self.instrument_config.logging_extra_processors,
190
197
  STRUCTLOG_FORMATTER_PROCESSOR,
191
198
  ],
@@ -213,7 +220,7 @@ class LoggingInstrument(Instrument[LoggingConfig]):
213
220
  )
214
221
  if self.instrument_config.service_debug
215
222
  else structlog.stdlib.ProcessorFormatter(
216
- foreign_pre_chain=STRUCTLOG_PRE_CHAIN_PROCESSORS,
223
+ foreign_pre_chain=[*STRUCTLOG_PRE_CHAIN_PROCESSORS, self._timestamper_processor],
217
224
  processors=[
218
225
  structlog.stdlib.ProcessorFormatter.remove_processors_meta,
219
226
  STRUCTLOG_FORMATTER_PROCESSOR,
@@ -2,7 +2,6 @@ from __future__ import annotations
2
2
  import dataclasses
3
3
  import logging
4
4
  import os
5
- import threading
6
5
  import typing
7
6
 
8
7
  import pydantic
@@ -200,17 +199,14 @@ class PyroscopeSpanProcessor(SpanProcessor):
200
199
  def on_start(self, span: Span, parent_context: Context | None = None) -> None: # noqa: ARG002
201
200
  if _is_root_span(span):
202
201
  formatted_span_id: typing.Final = format_span_id(span.context.span_id)
203
- thread_id: typing.Final = threading.get_ident()
204
-
205
202
  span.set_attribute(OTEL_PROFILE_ID_KEY, formatted_span_id)
206
- pyroscope.add_thread_tag(thread_id, PYROSCOPE_SPAN_ID_KEY, formatted_span_id)
207
- pyroscope.add_thread_tag(thread_id, PYROSCOPE_SPAN_NAME_KEY, span.name)
203
+ pyroscope.add_thread_tag(PYROSCOPE_SPAN_ID_KEY, formatted_span_id)
204
+ pyroscope.add_thread_tag(PYROSCOPE_SPAN_NAME_KEY, span.name)
208
205
 
209
206
  def on_end(self, span: ReadableSpan) -> None:
210
207
  if _is_root_span(span):
211
- thread_id: typing.Final = threading.get_ident()
212
- pyroscope.remove_thread_tag(thread_id, PYROSCOPE_SPAN_ID_KEY, format_span_id(span.context.span_id))
213
- pyroscope.remove_thread_tag(thread_id, PYROSCOPE_SPAN_NAME_KEY, span.name)
208
+ pyroscope.remove_thread_tag(PYROSCOPE_SPAN_ID_KEY, format_span_id(span.context.span_id))
209
+ pyroscope.remove_thread_tag(PYROSCOPE_SPAN_NAME_KEY, span.name)
214
210
 
215
211
  def force_flush(self, timeout_millis: int = 30000) -> bool: # noqa: ARG002 # pragma: no cover
216
212
  return True
@@ -56,7 +56,7 @@ dependencies = [
56
56
  "opentelemetry-instrumentation-asgi>=0.46b0",
57
57
  "orjson>=3.10.18",
58
58
  ]
59
- version = "1.2.4"
59
+ version = "1.3.0"
60
60
  authors = [{ name = "community-of-python" }]
61
61
 
62
62
  [project.optional-dependencies]
File without changes