Skip to content

Structlog processor#5

Open
apelsynca wants to merge 3 commits into
logtide-dev:mainfrom
apelsynca:structlog-processor
Open

Structlog processor#5
apelsynca wants to merge 3 commits into
logtide-dev:mainfrom
apelsynca:structlog-processor

Conversation

@apelsynca
Copy link
Copy Markdown

Short summary:

1: changed relative imports to absolute.

2:
added LogTideProcessor based on structlog, and tests for that. (and fixed tests)
does not requires structlog to be installed.

usage example:

from logtide_sdk.structlog import LogTideProcessor

# then somewhere in code:

structlog.configure_once(processors=[
    ...,
    ...,
    LogtideProcessor(client=logtide_client, service="service_name_string")
]

apelsynca added 3 commits May 25, 2026 08:13
Also changed pyproject.toml, to use dependency groups while testing.
Also generated uv.sync file (for those who use uv)

Fixed pytest asyncio mode to a normal one
Downsides: users might see unwantanted class names (python class names)
Upsides: users can now set non JSONable objects as metadata, and be
fine.
@Polliog
Copy link
Copy Markdown
Contributor

Polliog commented May 25, 2026

@
Thanks for this! A few things before merge:

  1. Blocker: middleware/__init__.py uses wrong absolute imports — logtide_sdk.flask should be logtide_sdk.middleware.flask (same for django/fastapi/starlette). Since they are in try/except ImportError: pass, all middleware silently fail to import (__all__ becomes []).

  2. The pydantic quickfix does not fully work. Adding default=repr only fixes the size calc. _process_value leaves unknown objects untouched, and the actual send (_send_logs/_send_batch) posts with json=payload and no default=, so it still raises TypeError at flush time. I would prefer your other idea: do the repr/serialization inside LogTideProcessor so metadata is JSON-safe before it reaches the SDK. Let us drop the json.dumps(..., default=repr) change.

  3. frozenset[str] annotation in structlog.py breaks Python 3.8 (PEP 585 needs 3.9+), and we declare requires-python = ">=3.8". Use typing.FrozenSet or from __future__ import annotations.

The structlog processor itself looks good 👍
@

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants