logbrew-sdk 0.1.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.
@@ -0,0 +1,191 @@
1
+ Metadata-Version: 2.4
2
+ Name: logbrew-sdk
3
+ Version: 0.1.0
4
+ Summary: Public LogBrew Python SDK for building, validating, and flushing event batches.
5
+ Author: LogBrew
6
+ License-Expression: MIT
7
+ Project-URL: Repository, https://github.com/LogBrewCo/sdk
8
+ Keywords: logbrew,observability,logs,traces,events
9
+ Classifier: Development Status :: 3 - Alpha
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Programming Language :: Python :: 3 :: Only
13
+ Classifier: Programming Language :: Python :: 3.11
14
+ Classifier: Programming Language :: Python :: 3.12
15
+ Classifier: Programming Language :: Python :: 3.13
16
+ Requires-Python: >=3.11
17
+ Description-Content-Type: text/markdown
18
+
19
+ # logbrew-sdk
20
+
21
+ Public Python SDK for creating LogBrew event batches, validating them locally, and flushing them through a transport.
22
+
23
+ ## Install
24
+
25
+ ```bash
26
+ python3 -m pip install logbrew-sdk
27
+ python3 -m logbrew_sdk.examples --help
28
+ python3 -m logbrew_sdk.examples --list
29
+ python3 -m logbrew_sdk.examples readme-example
30
+ python3 -m logbrew_sdk.examples real-user-smoke
31
+ python3 -m logbrew_sdk.examples
32
+ python3 -m logbrew_sdk.examples.readme_example
33
+ python3 -m logbrew_sdk.examples.real_user_smoke
34
+ ```
35
+
36
+ The built wheel should also carry `py.typed` and wheel metadata with the expected package description before install.
37
+ Normal installs also expose standard package metadata like `pip show logbrew-sdk`, `pip show -f logbrew-sdk`, `pip list --format=json`, `pip freeze`, and `importlib.metadata.version("logbrew-sdk")`. The plain `pip show` summary should keep the expected package name, version, summary, author, license expression, and `site-packages` install location.
38
+ The built source distribution should also carry `README.md`, `pyproject.toml`, `py.typed`, and the packaged `logbrew_sdk.examples.readme_example` plus `logbrew_sdk.examples.real_user_smoke` modules in the archive itself. Both wheel and source-distribution installs carry the expected `py.typed`, example modules, and dist-info metadata files in `site-packages`, and that installed metadata keeps the pip install command, fake `LOGBREW_API_KEY` placeholder, `preview_json()` guidance, and packaged examples entrypoint commands a user would expect from the package description. Those installs should also keep pip-written `INSTALLER`, `direct_url.json`, `--report`, `pip inspect`, plain `pip show` summary fields, `pip show -f` file listings, and `pip list --format=json` package listings plus the expected `pip freeze` file URL with sha256 provenance so tooling can confirm the package came from the expected wheel or source-distribution artifact, the installed environment should stay clean under `python -m pip check`, both the wheel and source-distribution paths should survive a clean `python -m pip uninstall -y logbrew-sdk` removal before reinstalling the same artifact, a small installed-user `python -m unittest` run should still succeed, the published README example should still run from the installed package on both the main install and the reinstall paths, and the packaged examples entrypoint should be discoverable and runnable through `python -m logbrew_sdk.examples --help`, `python -m logbrew_sdk.examples --list`, `python -m logbrew_sdk.examples readme-example`, `python -m logbrew_sdk.examples real-user-smoke`, `python -m logbrew_sdk.examples`, `python -m logbrew_sdk.examples.readme_example`, and `python -m logbrew_sdk.examples.real_user_smoke`, with both `--help` and `--list` printing copy-pasteable packaged-example commands, including explicit named README-example and real-user-smoke entrypoint commands plus the default no-argument `python -m logbrew_sdk.examples` path being called out explicitly as the `real-user-smoke` entrypoint, instead of only generic argument help or bare example names. A one-line direct requirements file derived from that freeze output should also reinstall cleanly under `python -m pip install --require-hashes -r ...` in a fresh virtual environment.
39
+ The installed module, public payload shape types like `ReleaseAttributes`, `SpanAttributes`, and `TraceparentContext`, `LogBrewClient`, `HttpTransport`, `RecordingTransport`, `SdkError`, `TransportResponse`, `TransportError`, W3C trace helpers like `parse_traceparent()`, `create_traceparent()`, and `span_attributes_from_traceparent()`, and key lifecycle methods like `create()`, `preview_json()`, `flush()`, `shutdown()`, `pending_events()`, `always_accept()`, and `TransportError.network()` also expose stable docstrings that tools like `help(...)` can show after install. Installed wheel and sdist paths now both prove the field-level typing metadata for commonly inspected attributes like `TransportResponse.status_code`, `TransportResponse.attempts`, and `RecordingTransport.sent_bodies`, prove the typed consumer through a temp `pyproject.toml`-driven mypy config, and prove a consumer-owned `Makefile` that wraps the installed-user typecheck, unittest, README-example, packaged-example, packaged examples list, packaged examples help, packaged examples entrypoint, packaged real-user example, and happy-path smoke commands instead of relying only on loose raw commands, with plain `make` printing copy-pasteable `make smoke-...` commands and the shorter `make smoke-run` path labeled explicitly as the `real-user-smoke` flow.
40
+
41
+ ## Example
42
+
43
+ ```python
44
+ import json
45
+ import sys
46
+
47
+ from logbrew_sdk import LogBrewClient, RecordingTransport
48
+
49
+ client = LogBrewClient.create(
50
+ api_key="LOGBREW_API_KEY",
51
+ sdk_name="logbrew-python",
52
+ sdk_version="0.1.0",
53
+ )
54
+
55
+ client.release(
56
+ "evt_release_001",
57
+ "2026-06-02T10:00:00Z",
58
+ {
59
+ "version": "1.2.3",
60
+ "commit": "abc123def456",
61
+ "notes": "Public release marker",
62
+ },
63
+ )
64
+ client.environment(
65
+ "evt_environment_001",
66
+ "2026-06-02T10:00:01Z",
67
+ {"name": "production", "region": "global"},
68
+ )
69
+ client.issue(
70
+ "evt_issue_001",
71
+ "2026-06-02T10:00:02Z",
72
+ {
73
+ "title": "Checkout timeout",
74
+ "level": "error",
75
+ "message": "Request timed out after retry budget",
76
+ },
77
+ )
78
+ client.log(
79
+ "evt_log_001",
80
+ "2026-06-02T10:00:03Z",
81
+ {"message": "worker started", "level": "info", "logger": "job-runner"},
82
+ )
83
+ client.span(
84
+ "evt_span_001",
85
+ "2026-06-02T10:00:04Z",
86
+ {
87
+ "name": "GET /health",
88
+ "traceId": "trace_001",
89
+ "spanId": "span_001",
90
+ "status": "ok",
91
+ "durationMs": 12.5,
92
+ },
93
+ )
94
+ client.action(
95
+ "evt_action_001",
96
+ "2026-06-02T10:00:05Z",
97
+ {"name": "deploy", "status": "success"},
98
+ )
99
+
100
+ print(client.preview_json())
101
+
102
+ transport = RecordingTransport.always_accept()
103
+ response = client.shutdown(transport)
104
+ print(
105
+ json.dumps(
106
+ {"ok": True, "status": response.status_code, "attempts": response.attempts, "events": 6}
107
+ ),
108
+ file=sys.stderr,
109
+ )
110
+ ```
111
+
112
+ Use a clearly fake placeholder like `LOGBREW_API_KEY` in local examples and tests. Call `flush()` or `shutdown()` to send queued events through a transport, and use `preview_json()` when you want a stable local JSON preview without sending anything.
113
+
114
+ ## Trace Context
115
+
116
+ Use the W3C helpers when a Python service needs to interoperate with distributed tracing headers:
117
+
118
+ ```python
119
+ from logbrew_sdk import parse_traceparent, span_attributes_from_traceparent
120
+
121
+ traceparent = "00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01"
122
+ context = parse_traceparent(traceparent)
123
+ attributes = span_attributes_from_traceparent(
124
+ traceparent,
125
+ name="GET /health",
126
+ span_id="b7ad6b7169203331",
127
+ status="ok",
128
+ duration_ms=12.5,
129
+ metadata={"service": "checkout"},
130
+ )
131
+ ```
132
+
133
+ `parse_traceparent()` validates W3C shape, rejects all-zero trace/span IDs, normalizes IDs to lowercase, and exposes the sampled flag. `span_attributes_from_traceparent()` returns LogBrew span attributes with `traceId` from the incoming trace and `parentSpanId` from the incoming parent span. FastAPI and Django integrations use these helpers automatically for valid inbound `traceparent` headers and start a fresh synthetic span when the header is missing or malformed.
134
+
135
+ ## HTTP Delivery
136
+
137
+ Use `HttpTransport` for real outbound delivery from server-side Python apps:
138
+
139
+ ```python
140
+ from logbrew_sdk import HttpTransport, LogBrewClient
141
+
142
+ client = LogBrewClient.create(
143
+ api_key="LOGBREW_API_KEY",
144
+ sdk_name="logbrew-python",
145
+ sdk_version="0.1.0",
146
+ )
147
+ transport = HttpTransport(
148
+ endpoint="https://api.logbrew.com/v1/events",
149
+ headers={"x-logbrew-source": "python-worker"},
150
+ )
151
+
152
+ client.log(
153
+ "evt_worker_started",
154
+ "2026-06-02T10:00:06Z",
155
+ {"message": "worker started", "level": "info", "logger": "worker"},
156
+ )
157
+ client.flush(transport)
158
+ ```
159
+
160
+ `HttpTransport` uses Python's standard-library HTTP stack, posts JSON, passes the SDK key through the `authorization` header, supports custom endpoint/header/timeout settings, and maps connection failures into retryable `TransportError.network(...)` failures so `LogBrewClient.flush()` can preserve queued events and retry.
161
+
162
+ ## Standard Logging
163
+
164
+ Use `LogBrewLoggingHandler` when an application already uses Python's standard `logging` module:
165
+
166
+ ```python
167
+ import logging
168
+
169
+ from logbrew_sdk import LogBrewClient, LogBrewLoggingHandler, RecordingTransport
170
+
171
+ client = LogBrewClient.create(
172
+ api_key="LOGBREW_API_KEY",
173
+ sdk_name="logbrew-python",
174
+ sdk_version="0.1.0",
175
+ )
176
+ transport = RecordingTransport.always_accept()
177
+ handler = LogBrewLoggingHandler(
178
+ client,
179
+ transport,
180
+ flush_on_emit=True,
181
+ metadata={"service": "checkout"},
182
+ )
183
+
184
+ logger = logging.getLogger("checkout.worker")
185
+ logger.addHandler(handler)
186
+ logger.setLevel(logging.INFO)
187
+
188
+ logger.info("worker started", extra={"order_id": "ord_123"})
189
+ ```
190
+
191
+ The handler does not change global logging configuration. It maps standard logging levels into LogBrew log levels, keeps the logger name, captures primitive `extra={...}` values as metadata, and records source file name, function, line, thread, and process names without sending the full source path by default. Exception type and message are captured when `exc_info` is present; full exception text is opt-in with `include_exception_text=True`.
@@ -0,0 +1,173 @@
1
+ # logbrew-sdk
2
+
3
+ Public Python SDK for creating LogBrew event batches, validating them locally, and flushing them through a transport.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ python3 -m pip install logbrew-sdk
9
+ python3 -m logbrew_sdk.examples --help
10
+ python3 -m logbrew_sdk.examples --list
11
+ python3 -m logbrew_sdk.examples readme-example
12
+ python3 -m logbrew_sdk.examples real-user-smoke
13
+ python3 -m logbrew_sdk.examples
14
+ python3 -m logbrew_sdk.examples.readme_example
15
+ python3 -m logbrew_sdk.examples.real_user_smoke
16
+ ```
17
+
18
+ The built wheel should also carry `py.typed` and wheel metadata with the expected package description before install.
19
+ Normal installs also expose standard package metadata like `pip show logbrew-sdk`, `pip show -f logbrew-sdk`, `pip list --format=json`, `pip freeze`, and `importlib.metadata.version("logbrew-sdk")`. The plain `pip show` summary should keep the expected package name, version, summary, author, license expression, and `site-packages` install location.
20
+ The built source distribution should also carry `README.md`, `pyproject.toml`, `py.typed`, and the packaged `logbrew_sdk.examples.readme_example` plus `logbrew_sdk.examples.real_user_smoke` modules in the archive itself. Both wheel and source-distribution installs carry the expected `py.typed`, example modules, and dist-info metadata files in `site-packages`, and that installed metadata keeps the pip install command, fake `LOGBREW_API_KEY` placeholder, `preview_json()` guidance, and packaged examples entrypoint commands a user would expect from the package description. Those installs should also keep pip-written `INSTALLER`, `direct_url.json`, `--report`, `pip inspect`, plain `pip show` summary fields, `pip show -f` file listings, and `pip list --format=json` package listings plus the expected `pip freeze` file URL with sha256 provenance so tooling can confirm the package came from the expected wheel or source-distribution artifact, the installed environment should stay clean under `python -m pip check`, both the wheel and source-distribution paths should survive a clean `python -m pip uninstall -y logbrew-sdk` removal before reinstalling the same artifact, a small installed-user `python -m unittest` run should still succeed, the published README example should still run from the installed package on both the main install and the reinstall paths, and the packaged examples entrypoint should be discoverable and runnable through `python -m logbrew_sdk.examples --help`, `python -m logbrew_sdk.examples --list`, `python -m logbrew_sdk.examples readme-example`, `python -m logbrew_sdk.examples real-user-smoke`, `python -m logbrew_sdk.examples`, `python -m logbrew_sdk.examples.readme_example`, and `python -m logbrew_sdk.examples.real_user_smoke`, with both `--help` and `--list` printing copy-pasteable packaged-example commands, including explicit named README-example and real-user-smoke entrypoint commands plus the default no-argument `python -m logbrew_sdk.examples` path being called out explicitly as the `real-user-smoke` entrypoint, instead of only generic argument help or bare example names. A one-line direct requirements file derived from that freeze output should also reinstall cleanly under `python -m pip install --require-hashes -r ...` in a fresh virtual environment.
21
+ The installed module, public payload shape types like `ReleaseAttributes`, `SpanAttributes`, and `TraceparentContext`, `LogBrewClient`, `HttpTransport`, `RecordingTransport`, `SdkError`, `TransportResponse`, `TransportError`, W3C trace helpers like `parse_traceparent()`, `create_traceparent()`, and `span_attributes_from_traceparent()`, and key lifecycle methods like `create()`, `preview_json()`, `flush()`, `shutdown()`, `pending_events()`, `always_accept()`, and `TransportError.network()` also expose stable docstrings that tools like `help(...)` can show after install. Installed wheel and sdist paths now both prove the field-level typing metadata for commonly inspected attributes like `TransportResponse.status_code`, `TransportResponse.attempts`, and `RecordingTransport.sent_bodies`, prove the typed consumer through a temp `pyproject.toml`-driven mypy config, and prove a consumer-owned `Makefile` that wraps the installed-user typecheck, unittest, README-example, packaged-example, packaged examples list, packaged examples help, packaged examples entrypoint, packaged real-user example, and happy-path smoke commands instead of relying only on loose raw commands, with plain `make` printing copy-pasteable `make smoke-...` commands and the shorter `make smoke-run` path labeled explicitly as the `real-user-smoke` flow.
22
+
23
+ ## Example
24
+
25
+ ```python
26
+ import json
27
+ import sys
28
+
29
+ from logbrew_sdk import LogBrewClient, RecordingTransport
30
+
31
+ client = LogBrewClient.create(
32
+ api_key="LOGBREW_API_KEY",
33
+ sdk_name="logbrew-python",
34
+ sdk_version="0.1.0",
35
+ )
36
+
37
+ client.release(
38
+ "evt_release_001",
39
+ "2026-06-02T10:00:00Z",
40
+ {
41
+ "version": "1.2.3",
42
+ "commit": "abc123def456",
43
+ "notes": "Public release marker",
44
+ },
45
+ )
46
+ client.environment(
47
+ "evt_environment_001",
48
+ "2026-06-02T10:00:01Z",
49
+ {"name": "production", "region": "global"},
50
+ )
51
+ client.issue(
52
+ "evt_issue_001",
53
+ "2026-06-02T10:00:02Z",
54
+ {
55
+ "title": "Checkout timeout",
56
+ "level": "error",
57
+ "message": "Request timed out after retry budget",
58
+ },
59
+ )
60
+ client.log(
61
+ "evt_log_001",
62
+ "2026-06-02T10:00:03Z",
63
+ {"message": "worker started", "level": "info", "logger": "job-runner"},
64
+ )
65
+ client.span(
66
+ "evt_span_001",
67
+ "2026-06-02T10:00:04Z",
68
+ {
69
+ "name": "GET /health",
70
+ "traceId": "trace_001",
71
+ "spanId": "span_001",
72
+ "status": "ok",
73
+ "durationMs": 12.5,
74
+ },
75
+ )
76
+ client.action(
77
+ "evt_action_001",
78
+ "2026-06-02T10:00:05Z",
79
+ {"name": "deploy", "status": "success"},
80
+ )
81
+
82
+ print(client.preview_json())
83
+
84
+ transport = RecordingTransport.always_accept()
85
+ response = client.shutdown(transport)
86
+ print(
87
+ json.dumps(
88
+ {"ok": True, "status": response.status_code, "attempts": response.attempts, "events": 6}
89
+ ),
90
+ file=sys.stderr,
91
+ )
92
+ ```
93
+
94
+ Use a clearly fake placeholder like `LOGBREW_API_KEY` in local examples and tests. Call `flush()` or `shutdown()` to send queued events through a transport, and use `preview_json()` when you want a stable local JSON preview without sending anything.
95
+
96
+ ## Trace Context
97
+
98
+ Use the W3C helpers when a Python service needs to interoperate with distributed tracing headers:
99
+
100
+ ```python
101
+ from logbrew_sdk import parse_traceparent, span_attributes_from_traceparent
102
+
103
+ traceparent = "00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01"
104
+ context = parse_traceparent(traceparent)
105
+ attributes = span_attributes_from_traceparent(
106
+ traceparent,
107
+ name="GET /health",
108
+ span_id="b7ad6b7169203331",
109
+ status="ok",
110
+ duration_ms=12.5,
111
+ metadata={"service": "checkout"},
112
+ )
113
+ ```
114
+
115
+ `parse_traceparent()` validates W3C shape, rejects all-zero trace/span IDs, normalizes IDs to lowercase, and exposes the sampled flag. `span_attributes_from_traceparent()` returns LogBrew span attributes with `traceId` from the incoming trace and `parentSpanId` from the incoming parent span. FastAPI and Django integrations use these helpers automatically for valid inbound `traceparent` headers and start a fresh synthetic span when the header is missing or malformed.
116
+
117
+ ## HTTP Delivery
118
+
119
+ Use `HttpTransport` for real outbound delivery from server-side Python apps:
120
+
121
+ ```python
122
+ from logbrew_sdk import HttpTransport, LogBrewClient
123
+
124
+ client = LogBrewClient.create(
125
+ api_key="LOGBREW_API_KEY",
126
+ sdk_name="logbrew-python",
127
+ sdk_version="0.1.0",
128
+ )
129
+ transport = HttpTransport(
130
+ endpoint="https://api.logbrew.com/v1/events",
131
+ headers={"x-logbrew-source": "python-worker"},
132
+ )
133
+
134
+ client.log(
135
+ "evt_worker_started",
136
+ "2026-06-02T10:00:06Z",
137
+ {"message": "worker started", "level": "info", "logger": "worker"},
138
+ )
139
+ client.flush(transport)
140
+ ```
141
+
142
+ `HttpTransport` uses Python's standard-library HTTP stack, posts JSON, passes the SDK key through the `authorization` header, supports custom endpoint/header/timeout settings, and maps connection failures into retryable `TransportError.network(...)` failures so `LogBrewClient.flush()` can preserve queued events and retry.
143
+
144
+ ## Standard Logging
145
+
146
+ Use `LogBrewLoggingHandler` when an application already uses Python's standard `logging` module:
147
+
148
+ ```python
149
+ import logging
150
+
151
+ from logbrew_sdk import LogBrewClient, LogBrewLoggingHandler, RecordingTransport
152
+
153
+ client = LogBrewClient.create(
154
+ api_key="LOGBREW_API_KEY",
155
+ sdk_name="logbrew-python",
156
+ sdk_version="0.1.0",
157
+ )
158
+ transport = RecordingTransport.always_accept()
159
+ handler = LogBrewLoggingHandler(
160
+ client,
161
+ transport,
162
+ flush_on_emit=True,
163
+ metadata={"service": "checkout"},
164
+ )
165
+
166
+ logger = logging.getLogger("checkout.worker")
167
+ logger.addHandler(handler)
168
+ logger.setLevel(logging.INFO)
169
+
170
+ logger.info("worker started", extra={"order_id": "ord_123"})
171
+ ```
172
+
173
+ The handler does not change global logging configuration. It maps standard logging levels into LogBrew log levels, keeps the logger name, captures primitive `extra={...}` values as metadata, and records source file name, function, line, thread, and process names without sending the full source path by default. Exception type and message are captured when `exc_info` is present; full exception text is opt-in with `include_exception_text=True`.
@@ -0,0 +1,36 @@
1
+ [build-system]
2
+ requires = ["setuptools>=80"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "logbrew-sdk"
7
+ version = "0.1.0"
8
+ description = "Public LogBrew Python SDK for building, validating, and flushing event batches."
9
+ readme = "README.md"
10
+ license = "MIT"
11
+ requires-python = ">=3.11"
12
+ authors = [
13
+ { name = "LogBrew" }
14
+ ]
15
+ keywords = ["logbrew", "observability", "logs", "traces", "events"]
16
+ classifiers = [
17
+ "Development Status :: 3 - Alpha",
18
+ "Intended Audience :: Developers",
19
+ "Programming Language :: Python :: 3",
20
+ "Programming Language :: Python :: 3 :: Only",
21
+ "Programming Language :: Python :: 3.11",
22
+ "Programming Language :: Python :: 3.12",
23
+ "Programming Language :: Python :: 3.13"
24
+ ]
25
+
26
+ [project.urls]
27
+ Repository = "https://github.com/LogBrewCo/sdk"
28
+
29
+ [tool.setuptools]
30
+ package-dir = {"" = "src"}
31
+
32
+ [tool.setuptools.packages.find]
33
+ where = ["src"]
34
+
35
+ [tool.setuptools.package-data]
36
+ logbrew_sdk = ["py.typed"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+