Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Per-field truncation / summarization for large nested log fields

Open
#799 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
35/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
python
Domain
backend

Research direction

Start by reading the existing processors in structlog.processors and their tests to understand the processor API and conventions. The issue proposes field-specific string, list, and nested-dictionary limits but does not identify an entry point or define behavior for edge cases; clarify the API and expected summaries with maintainers before implementation. Done means a built-in processor handles the requested per-field limits and has tests covering its behavior.

Written by the indexing model from the issue text.

Description

Summary

It would be useful if structlog provided a built-in processor for per-field truncation / summarization of large values, especially nested dicts and lists.

Problem

Some fields in structured logs are much larger than others, for example:

  • request / response payloads
  • nested kwargs
  • prompt text
  • model outputs

These can overwhelm otherwise readable logs. Global string truncation is not enough; what is often needed is field-aware summarization.

Desired behavior

Something like a built-in processor where selected fields can be limited independently, for example:

  • truncate long strings for prompt
  • limit list length for messages
  • limit depth / keys for nested dicts like payload

Example

log.debug(
    "completion.request",
    prompt=very_large_prompt,
    messages=large_messages,
    extra_body=large_nested_dict,
)

Possible API shape:

structlog.processors.truncate_fields(
    {
        "prompt": {"max_length": 300},
        "messages": {"max_items": 2, "max_string_length": 200},
        "extra_body": {"max_depth": 1, "max_keys": 10},
    }
)

Why

This seems like a common structured-logging need: preserve useful context while keeping summary/debug logs readable without writing a custom processor every time.

Would maintainers be open to something like this?

Dominant language
Python
Stars
5k
Forks
302
Avg merge
17m
Merged PRs (30d)
4

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from hynek/structlog

All issues in hynek/structlog

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.