narrativetrace-structlog 0.1.1__tar.gz → 0.1.2__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.
@@ -23,3 +23,7 @@ build/
23
23
  # Local tooling state (contains credentials — never commit)
24
24
 
25
25
  # Local tooling state (holds host-absolute paths)
26
+
27
+ # narrativetrace-pytest's default per-test artifact directory -- on by default, opt out with
28
+ # NARRATIVETRACE_OUTPUT=false (see documentation/what-to-commit.md)
29
+ narrative-traces/
@@ -7,7 +7,7 @@ Parameters
7
7
 
8
8
  Licensor: Empower Agile
9
9
 
10
- Licensed Work: NarrativeTrace for Python (the narrativetrace PyPI distributions) version 0.1.1. The Licensed Work is (c) 2026 Empower Agile.
10
+ Licensed Work: NarrativeTrace for Python (the narrativetrace PyPI distributions) version 0.1.2. The Licensed Work is (c) 2026 Empower Agile.
11
11
 
12
12
  Additional Use Grant: You may make production use of the Licensed Work for any
13
13
  purpose, including internal use and use in products and
@@ -18,7 +18,7 @@ Additional Use Grant: You may make production use of the Licensed Work for any
18
18
  parties as a logging, tracing, or code-narrative product
19
19
  or service.
20
20
 
21
- Change Date: Four years from the date the Licensed Work is published. (2030-09-11 for this version)
21
+ Change Date: Four years from the date the Licensed Work is published. (2030-09-16 for this version)
22
22
 
23
23
  Change License: Apache License, Version 2.0
24
24
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: narrativetrace-structlog
3
- Version: 0.1.1
3
+ Version: 0.1.2
4
4
  Summary: structlog processor injecting narrativetrace correlation keys
5
5
  Project-URL: Homepage, https://github.com/narrativetrace/narrativetrace-python
6
6
  Project-URL: Source, https://github.com/narrativetrace/narrativetrace-python
@@ -10,8 +10,7 @@ License-File: LICENSE
10
10
  Classifier: Typing :: Typed
11
11
  Requires-Python: >=3.12
12
12
  Requires-Dist: narrativetrace
13
- Provides-Extra: structlog
14
- Requires-Dist: structlog>=24; extra == 'structlog'
13
+ Requires-Dist: structlog>=24
15
14
  Description-Content-Type: text/markdown
16
15
 
17
16
  # narrativetrace-structlog
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "narrativetrace-structlog"
3
- version = "0.1.1"
3
+ version = "0.1.2"
4
4
  description = "structlog processor injecting narrativetrace correlation keys"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.12"
@@ -10,21 +10,15 @@ license = "BUSL-1.1"
10
10
  license-files = ["LICENSE"]
11
11
  authors = [{ name = "narrativetrace contributors" }]
12
12
  classifiers = ["Typing :: Typed"]
13
- dependencies = ["narrativetrace"]
13
+ dependencies = ["narrativetrace", "structlog>=24"]
14
14
 
15
15
  [project.urls]
16
16
  Homepage = "https://github.com/narrativetrace/narrativetrace-python"
17
17
  Source = "https://github.com/narrativetrace/narrativetrace-python"
18
18
 
19
- [project.optional-dependencies]
20
- structlog = ["structlog>=24"]
21
-
22
19
  [build-system]
23
20
  requires = ["hatchling"]
24
21
  build-backend = "hatchling.build"
25
22
 
26
23
  [tool.hatch.build.targets.wheel]
27
24
  packages = ["src/narrativetrace_structlog"]
28
-
29
- [dependency-groups]
30
- dev = ["structlog>=24"]
@@ -22,19 +22,26 @@ Usage::
22
22
 
23
23
  from __future__ import annotations
24
24
 
25
+ from collections.abc import MutableMapping
25
26
  from typing import Any
26
27
 
27
28
  from narrativetrace import current_scope_keys
28
29
 
29
- __version__ = "0.1.1"
30
+ __version__ = "0.1.2"
30
31
 
31
32
  __all__ = ["narrative_context_processor"]
32
33
 
33
34
 
34
35
  def narrative_context_processor(
35
- _logger: Any, _method_name: str, event_dict: dict[str, Any]
36
- ) -> dict[str, Any]:
37
- """A structlog processor adding the current scope's correlation keys (without overwriting)."""
36
+ _logger: Any, _method_name: str, event_dict: MutableMapping[str, Any]
37
+ ) -> MutableMapping[str, Any]:
38
+ """A structlog processor adding the current scope's correlation keys (without overwriting).
39
+
40
+ Typed against ``MutableMapping``, not ``dict``: structlog's own ``Processor`` protocol takes
41
+ the broader type, so a narrower one here fails strict mypy the moment a caller feeds this
42
+ straight into ``structlog.configure(processors=[...])`` -- found running exactly that, this
43
+ guide's own documented usage example, under this repository's strict mypy gate.
44
+ """
38
45
  for key, value in current_scope_keys().items():
39
46
  event_dict.setdefault(key, value)
40
47
  return event_dict
@@ -57,7 +57,12 @@ class TestProcessor:
57
57
  assert narrative_context_processor(None, "info", {"event": "hi"}) == {"event": "hi"}
58
58
 
59
59
  def test_emits_identical_keys_to_stdlib_filter(self) -> None:
60
- """The structlog processor and the stdlib filter must produce the same key set."""
60
+ """The structlog processor and the stdlib filter must produce the same key set, with one
61
+ documented exception: the stdlib filter also always defaults `traceName`/`runName` to `""`
62
+ (2026-09-13 ruling) so a `%`-style format string referencing either never raises
63
+ `KeyError` on a record with no active trace/run -- structlog's event dict needs no such
64
+ protection, since a missing dict key is never a formatting crash the way an absent
65
+ LogRecord attribute is."""
61
66
  _enter_span()
62
67
  with request_log_scope({"httpMethod": "GET"}):
63
68
  processor_keys = set(narrative_context_processor(None, "info", {})) - {"event"}
@@ -67,4 +72,4 @@ class TestProcessor:
67
72
  base = set(logging.LogRecord("t", logging.INFO, __file__, 1, "m", None, None).__dict__)
68
73
  filter_keys = set(record.__dict__) - base
69
74
 
70
- assert processor_keys == filter_keys
75
+ assert processor_keys == filter_keys - {"runName"}