convalesce-emit 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.
- convalesce_emit-0.1.0/.gitignore +23 -0
- convalesce_emit-0.1.0/LICENSE +202 -0
- convalesce_emit-0.1.0/PKG-INFO +58 -0
- convalesce_emit-0.1.0/README.md +40 -0
- convalesce_emit-0.1.0/pyproject.toml +72 -0
- convalesce_emit-0.1.0/src/convalesce_emit/__init__.py +46 -0
- convalesce_emit-0.1.0/src/convalesce_emit/_version.py +10 -0
- convalesce_emit-0.1.0/src/convalesce_emit/client.py +225 -0
- convalesce_emit-0.1.0/src/convalesce_emit/config.py +161 -0
- convalesce_emit-0.1.0/src/convalesce_emit/envelope.py +109 -0
- convalesce_emit-0.1.0/src/convalesce_emit/errors.py +54 -0
- convalesce_emit-0.1.0/src/convalesce_emit/protocols.py +51 -0
- convalesce_emit-0.1.0/src/convalesce_emit/redact.py +77 -0
- convalesce_emit-0.1.0/src/convalesce_emit/serialize.py +230 -0
- convalesce_emit-0.1.0/src/convalesce_emit/test/__init__.py +0 -0
- convalesce_emit-0.1.0/src/convalesce_emit/test/test_client.py +264 -0
- convalesce_emit-0.1.0/src/convalesce_emit/test/test_config.py +96 -0
- convalesce_emit-0.1.0/src/convalesce_emit/test/test_envelope.py +75 -0
- convalesce_emit-0.1.0/src/convalesce_emit/test/test_redact.py +70 -0
- convalesce_emit-0.1.0/src/convalesce_emit/test/test_serialize.py +169 -0
- convalesce_emit-0.1.0/src/convalesce_emit/toolinfo.py +34 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Python
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*.egg-info/
|
|
5
|
+
build/
|
|
6
|
+
dist/
|
|
7
|
+
.venv/
|
|
8
|
+
venv/
|
|
9
|
+
.pytest_cache/
|
|
10
|
+
.ruff_cache/
|
|
11
|
+
.mypy_cache/
|
|
12
|
+
|
|
13
|
+
# Java
|
|
14
|
+
.gradle/
|
|
15
|
+
java/**/build/
|
|
16
|
+
*.class
|
|
17
|
+
|
|
18
|
+
# Lint and type-check configuration is local tooling, not shipped source.
|
|
19
|
+
.flake8
|
|
20
|
+
.isort.cfg
|
|
21
|
+
.pylintrc
|
|
22
|
+
mypy.ini
|
|
23
|
+
.ruff.toml
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright 2026 Convalesce
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: convalesce-emit
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Forward a data tool's own output to Convalesce, unchanged.
|
|
5
|
+
Project-URL: Homepage, https://convalesce.com
|
|
6
|
+
Project-URL: Documentation, https://docs.convalesce.com
|
|
7
|
+
Project-URL: Source, https://github.com/convalesce/emit
|
|
8
|
+
Author: Convalesce
|
|
9
|
+
License-Expression: Apache-2.0
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Keywords: airflow,dagster,data observability,lineage,prefect
|
|
12
|
+
Classifier: Development Status :: 3 - Alpha
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
16
|
+
Requires-Python: >=3.9
|
|
17
|
+
Description-Content-Type: text/markdown
|
|
18
|
+
|
|
19
|
+
# convalesce-emit
|
|
20
|
+
|
|
21
|
+
Forwards a data tool's own output to Convalesce, unchanged. This is the
|
|
22
|
+
transport the tool plugins share: Airflow, Dagster, Prefect and Great
|
|
23
|
+
Expectations each install it as their one dependency.
|
|
24
|
+
|
|
25
|
+
It has **no dependencies of its own**. Transport is `urllib` from the
|
|
26
|
+
standard library, so it installs into an existing pipeline environment
|
|
27
|
+
without touching a resolution that already works.
|
|
28
|
+
|
|
29
|
+
## Install
|
|
30
|
+
|
|
31
|
+
```sh
|
|
32
|
+
pip install convalesce-emit-airflow # or -dagster, -prefect, -gx
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Configure
|
|
36
|
+
|
|
37
|
+
Set these on the worker; no code changes are needed.
|
|
38
|
+
|
|
39
|
+
| Variable | Default | |
|
|
40
|
+
| --- | --- | --- |
|
|
41
|
+
| `CONVALESCE_INGEST_KEY` | none | required unless dry-running |
|
|
42
|
+
| `CONVALESCE_ENDPOINT` | `https://api.convalesce.io` | |
|
|
43
|
+
| `CONVALESCE_DRY_RUN` | `false` | build envelopes, log them, send nothing |
|
|
44
|
+
| `CONVALESCE_ENABLED` | `true` | set `false` to switch off entirely |
|
|
45
|
+
| `CONVALESCE_BATCH_SIZE` | `50` | |
|
|
46
|
+
| `CONVALESCE_MAX_RETRIES` | `3` | |
|
|
47
|
+
| `CONVALESCE_TIMEOUT` | `10` | seconds |
|
|
48
|
+
|
|
49
|
+
Nothing names an account: the ingest key carries that.
|
|
50
|
+
|
|
51
|
+
## Links
|
|
52
|
+
|
|
53
|
+
- [Repository](https://github.com/convalesce/emit), with what these
|
|
54
|
+
plugins do and why.
|
|
55
|
+
- [Versions verified](https://github.com/convalesce/emit/blob/main/docs/version-support.md),
|
|
56
|
+
for each tool, on real installs.
|
|
57
|
+
- [Develop](https://github.com/convalesce/emit/blob/main/python/README.md):
|
|
58
|
+
`make lint`, `make test`.
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# convalesce-emit
|
|
2
|
+
|
|
3
|
+
Forwards a data tool's own output to Convalesce, unchanged. This is the
|
|
4
|
+
transport the tool plugins share: Airflow, Dagster, Prefect and Great
|
|
5
|
+
Expectations each install it as their one dependency.
|
|
6
|
+
|
|
7
|
+
It has **no dependencies of its own**. Transport is `urllib` from the
|
|
8
|
+
standard library, so it installs into an existing pipeline environment
|
|
9
|
+
without touching a resolution that already works.
|
|
10
|
+
|
|
11
|
+
## Install
|
|
12
|
+
|
|
13
|
+
```sh
|
|
14
|
+
pip install convalesce-emit-airflow # or -dagster, -prefect, -gx
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Configure
|
|
18
|
+
|
|
19
|
+
Set these on the worker; no code changes are needed.
|
|
20
|
+
|
|
21
|
+
| Variable | Default | |
|
|
22
|
+
| --- | --- | --- |
|
|
23
|
+
| `CONVALESCE_INGEST_KEY` | none | required unless dry-running |
|
|
24
|
+
| `CONVALESCE_ENDPOINT` | `https://api.convalesce.io` | |
|
|
25
|
+
| `CONVALESCE_DRY_RUN` | `false` | build envelopes, log them, send nothing |
|
|
26
|
+
| `CONVALESCE_ENABLED` | `true` | set `false` to switch off entirely |
|
|
27
|
+
| `CONVALESCE_BATCH_SIZE` | `50` | |
|
|
28
|
+
| `CONVALESCE_MAX_RETRIES` | `3` | |
|
|
29
|
+
| `CONVALESCE_TIMEOUT` | `10` | seconds |
|
|
30
|
+
|
|
31
|
+
Nothing names an account: the ingest key carries that.
|
|
32
|
+
|
|
33
|
+
## Links
|
|
34
|
+
|
|
35
|
+
- [Repository](https://github.com/convalesce/emit), with what these
|
|
36
|
+
plugins do and why.
|
|
37
|
+
- [Versions verified](https://github.com/convalesce/emit/blob/main/docs/version-support.md),
|
|
38
|
+
for each tool, on real installs.
|
|
39
|
+
- [Develop](https://github.com/convalesce/emit/blob/main/python/README.md):
|
|
40
|
+
`make lint`, `make test`.
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "convalesce-emit"
|
|
3
|
+
dynamic = ["version"]
|
|
4
|
+
description = "Forward a data tool's own output to Convalesce, unchanged."
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
license = "Apache-2.0"
|
|
7
|
+
license-files = ["LICENSE"]
|
|
8
|
+
authors = [{ name = "Convalesce" }]
|
|
9
|
+
keywords = ["data observability", "lineage", "airflow", "dagster", "prefect"]
|
|
10
|
+
classifiers = [
|
|
11
|
+
"Development Status :: 3 - Alpha",
|
|
12
|
+
"Intended Audience :: Developers",
|
|
13
|
+
"Programming Language :: Python :: 3",
|
|
14
|
+
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
15
|
+
]
|
|
16
|
+
# Deliberately wider than the other Convalesce Python repositories, which pin
|
|
17
|
+
# >=3.12,<3.13. This one installs into a customer's Airflow or Dagster, so it
|
|
18
|
+
# has to meet their interpreter rather than ask them to meet ours.
|
|
19
|
+
requires-python = ">=3.9"
|
|
20
|
+
# No dependencies, on purpose: it must never disturb a resolution that already
|
|
21
|
+
# works in someone else's pipeline. Transport is urllib from the stdlib.
|
|
22
|
+
dependencies = []
|
|
23
|
+
|
|
24
|
+
[dependency-groups]
|
|
25
|
+
dev = [
|
|
26
|
+
{ include-group = "lint" },
|
|
27
|
+
{ include-group = "test" },
|
|
28
|
+
]
|
|
29
|
+
lint = [
|
|
30
|
+
"black>=25.1",
|
|
31
|
+
"flake8>=7.1",
|
|
32
|
+
"isort>=6.0",
|
|
33
|
+
"mypy>=1.14",
|
|
34
|
+
"pylint>=3.3",
|
|
35
|
+
]
|
|
36
|
+
test = [
|
|
37
|
+
"pytest>=8.3",
|
|
38
|
+
"pytest-timeout>=2.3",
|
|
39
|
+
]
|
|
40
|
+
|
|
41
|
+
[project.urls]
|
|
42
|
+
Homepage = "https://convalesce.com"
|
|
43
|
+
Documentation = "https://docs.convalesce.com"
|
|
44
|
+
Source = "https://github.com/convalesce/emit"
|
|
45
|
+
|
|
46
|
+
[build-system]
|
|
47
|
+
requires = ["hatchling"]
|
|
48
|
+
build-backend = "hatchling.build"
|
|
49
|
+
|
|
50
|
+
[tool.hatch.version]
|
|
51
|
+
path = "src/convalesce_emit/_version.py"
|
|
52
|
+
|
|
53
|
+
[tool.hatch.build.targets.sdist]
|
|
54
|
+
# Only this package. Without it hatch ships everything under the
|
|
55
|
+
# project directory, which for the core is every plugin and its tests.
|
|
56
|
+
only-include = ["src/convalesce_emit"]
|
|
57
|
+
|
|
58
|
+
[tool.hatch.build.targets.wheel]
|
|
59
|
+
packages = ["src/convalesce_emit"]
|
|
60
|
+
|
|
61
|
+
# Tests live beside the code, as they do across these repos, but a package
|
|
62
|
+
# installed into a customer's Airflow has no use for them.
|
|
63
|
+
exclude = ["**/test/**"]
|
|
64
|
+
|
|
65
|
+
[tool.black]
|
|
66
|
+
line-length = 81
|
|
67
|
+
target-version = ["py39"]
|
|
68
|
+
|
|
69
|
+
[tool.pytest.ini_options]
|
|
70
|
+
testpaths = ["src", "plugins"]
|
|
71
|
+
norecursedirs = [".git", ".venv", "build", "dist"]
|
|
72
|
+
addopts = "-p no:warnings --tb=native -rpa --durations=3 --timeout=60"
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Send a tool's own output to Convalesce, unchanged.
|
|
3
|
+
|
|
4
|
+
This package connects and forwards. It does not parse, map or resolve
|
|
5
|
+
anything: whatever the tool handed us goes across as-is, and every bit of
|
|
6
|
+
interpretation happens after it arrives. That is the point -- improving how a
|
|
7
|
+
payload is understood never requires anyone to upgrade this package.
|
|
8
|
+
|
|
9
|
+
The names below are re-exported for callers embedding the emitter directly.
|
|
10
|
+
Within the package, modules import each other by alias, never by name.
|
|
11
|
+
|
|
12
|
+
Import as:
|
|
13
|
+
|
|
14
|
+
import convalesce_emit as cemit
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
import logging
|
|
18
|
+
|
|
19
|
+
from convalesce_emit._version import __version__
|
|
20
|
+
from convalesce_emit.client import Emitter, send_one
|
|
21
|
+
from convalesce_emit.config import Config
|
|
22
|
+
from convalesce_emit.envelope import ENVELOPE_VERSION, Observation, build
|
|
23
|
+
from convalesce_emit.errors import ConfigError, EmitError, TransportError
|
|
24
|
+
from convalesce_emit.protocols import EmitterLike
|
|
25
|
+
from convalesce_emit.redact import redact_samples
|
|
26
|
+
from convalesce_emit.serialize import dump
|
|
27
|
+
from convalesce_emit.toolinfo import version_of
|
|
28
|
+
|
|
29
|
+
_LOG = logging.getLogger(__name__)
|
|
30
|
+
|
|
31
|
+
__all__ = [
|
|
32
|
+
"ENVELOPE_VERSION",
|
|
33
|
+
"Config",
|
|
34
|
+
"ConfigError",
|
|
35
|
+
"EmitError",
|
|
36
|
+
"Emitter",
|
|
37
|
+
"EmitterLike",
|
|
38
|
+
"Observation",
|
|
39
|
+
"TransportError",
|
|
40
|
+
"__version__",
|
|
41
|
+
"build",
|
|
42
|
+
"dump",
|
|
43
|
+
"redact_samples",
|
|
44
|
+
"send_one",
|
|
45
|
+
"version_of",
|
|
46
|
+
]
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Transport: batches observations and posts them.
|
|
3
|
+
|
|
4
|
+
Built on `urllib` rather than `requests` or `httpx`. This runs inside someone
|
|
5
|
+
else's Airflow, Dagster or Prefect process, and the one thing it must never
|
|
6
|
+
do is drag a dependency into a resolution that already works.
|
|
7
|
+
|
|
8
|
+
Nothing here raises into the caller. A customer's DAG must not go red because
|
|
9
|
+
our endpoint had a bad minute: we are watching their pipeline, not standing
|
|
10
|
+
in it.
|
|
11
|
+
|
|
12
|
+
Import as:
|
|
13
|
+
|
|
14
|
+
import convalesce_emit.client as ceclient
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
import json
|
|
18
|
+
import logging
|
|
19
|
+
import random
|
|
20
|
+
import threading
|
|
21
|
+
import time
|
|
22
|
+
import urllib.error
|
|
23
|
+
import urllib.request
|
|
24
|
+
from typing import Any, Dict, List, Optional
|
|
25
|
+
|
|
26
|
+
import convalesce_emit._version as ceversio
|
|
27
|
+
import convalesce_emit.config as ceconfig
|
|
28
|
+
import convalesce_emit.envelope as ceenvelo
|
|
29
|
+
import convalesce_emit.errors as ceerrors
|
|
30
|
+
import convalesce_emit.protocols as ceproto
|
|
31
|
+
|
|
32
|
+
_LOG = logging.getLogger(__name__)
|
|
33
|
+
|
|
34
|
+
# Retry only what a retry can fix. A 400 means the receiver understood us and
|
|
35
|
+
# said no; sending it again just wastes the pipeline's time.
|
|
36
|
+
RETRYABLE_STATUS = frozenset({408, 425, 429, 500, 502, 503, 504})
|
|
37
|
+
|
|
38
|
+
_OBSERVATIONS_PATH = "/v1/observations"
|
|
39
|
+
# Caps the backoff so a long outage does not park a worker thread for
|
|
40
|
+
# minutes at a time.
|
|
41
|
+
_MAX_BACKOFF_SECONDS = 30
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
# #############################################################################
|
|
45
|
+
# Emitter
|
|
46
|
+
# #############################################################################
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
class Emitter:
|
|
50
|
+
"""
|
|
51
|
+
Sends a tool's raw output to Convalesce.
|
|
52
|
+
|
|
53
|
+
:param config: where to send and how hard to try; read from the
|
|
54
|
+
environment when not given
|
|
55
|
+
"""
|
|
56
|
+
|
|
57
|
+
def __init__(self, config: Optional[ceconfig.Config] = None) -> None:
|
|
58
|
+
self.config = config or ceconfig.Config.from_env()
|
|
59
|
+
self.config.validate()
|
|
60
|
+
self._lock = threading.Lock()
|
|
61
|
+
self._batch: List[ceenvelo.Observation] = []
|
|
62
|
+
|
|
63
|
+
def __enter__(self) -> "Emitter":
|
|
64
|
+
return self
|
|
65
|
+
|
|
66
|
+
def __exit__(self, *_exc: object) -> None:
|
|
67
|
+
self.close()
|
|
68
|
+
|
|
69
|
+
def emit(
|
|
70
|
+
self,
|
|
71
|
+
*,
|
|
72
|
+
tool: str,
|
|
73
|
+
event: str,
|
|
74
|
+
payload: Any,
|
|
75
|
+
tool_version: Optional[str] = None,
|
|
76
|
+
) -> None:
|
|
77
|
+
"""
|
|
78
|
+
Queue one observation, sending the batch when it is full.
|
|
79
|
+
|
|
80
|
+
:param tool: which tool produced this
|
|
81
|
+
:param event: which callback fired
|
|
82
|
+
:param payload: the tool's own output, untouched
|
|
83
|
+
:param tool_version: the tool's version, where it could be read
|
|
84
|
+
:return: nothing
|
|
85
|
+
"""
|
|
86
|
+
if not self.config.enabled:
|
|
87
|
+
return
|
|
88
|
+
observation = ceenvelo.build(
|
|
89
|
+
tool=tool,
|
|
90
|
+
event=event,
|
|
91
|
+
payload=payload,
|
|
92
|
+
tool_version=tool_version,
|
|
93
|
+
)
|
|
94
|
+
with self._lock:
|
|
95
|
+
self._batch.append(observation)
|
|
96
|
+
ready = len(self._batch) >= self.config.batch_size
|
|
97
|
+
if ready:
|
|
98
|
+
self.flush()
|
|
99
|
+
|
|
100
|
+
def flush(self) -> None:
|
|
101
|
+
"""
|
|
102
|
+
Send whatever is queued, logging rather than raising on failure.
|
|
103
|
+
|
|
104
|
+
:return: nothing
|
|
105
|
+
"""
|
|
106
|
+
with self._lock:
|
|
107
|
+
batch, self._batch = self._batch, []
|
|
108
|
+
if not batch:
|
|
109
|
+
return
|
|
110
|
+
if self.config.dry_run:
|
|
111
|
+
for observation in batch:
|
|
112
|
+
_LOG.info(
|
|
113
|
+
"convalesce dry-run: %s",
|
|
114
|
+
json.dumps(observation.to_dict(), default=str),
|
|
115
|
+
)
|
|
116
|
+
return
|
|
117
|
+
try:
|
|
118
|
+
self._post(batch)
|
|
119
|
+
except Exception as exc: # pylint: disable=broad-exception-caught
|
|
120
|
+
# Deliberately broad: see the module docstring. Anything escaping
|
|
121
|
+
# here would surface inside the customer's task.
|
|
122
|
+
_LOG.warning(
|
|
123
|
+
"convalesce: dropped %d observation(s): %s", len(batch), exc
|
|
124
|
+
)
|
|
125
|
+
|
|
126
|
+
def close(self) -> None:
|
|
127
|
+
"""
|
|
128
|
+
Flush anything still queued.
|
|
129
|
+
|
|
130
|
+
:return: nothing
|
|
131
|
+
"""
|
|
132
|
+
self.flush()
|
|
133
|
+
|
|
134
|
+
def _post(self, batch: List[ceenvelo.Observation]) -> None:
|
|
135
|
+
"""
|
|
136
|
+
Send one batch, retrying what a retry can fix.
|
|
137
|
+
|
|
138
|
+
:param batch: observations to deliver
|
|
139
|
+
:return: nothing
|
|
140
|
+
:raises TransportError: if every attempt failed
|
|
141
|
+
"""
|
|
142
|
+
payload = {"observations": [obs.to_dict() for obs in batch]}
|
|
143
|
+
body = json.dumps(payload, default=str).encode("utf-8")
|
|
144
|
+
url = self.config.endpoint.rstrip("/") + _OBSERVATIONS_PATH
|
|
145
|
+
for attempt in range(self.config.max_retries + 1):
|
|
146
|
+
try:
|
|
147
|
+
self._attempt(url, body)
|
|
148
|
+
return
|
|
149
|
+
except ceerrors.TransportError as exc:
|
|
150
|
+
retryable = exc.status is None or exc.status in RETRYABLE_STATUS
|
|
151
|
+
if not retryable or attempt == self.config.max_retries:
|
|
152
|
+
raise
|
|
153
|
+
# Full jitter: several workers failing at once should not
|
|
154
|
+
# come back in lockstep.
|
|
155
|
+
delay = min(2**attempt, _MAX_BACKOFF_SECONDS) * random.random()
|
|
156
|
+
_LOG.debug("convalesce: retrying in %.2fs (%s)", delay, exc)
|
|
157
|
+
time.sleep(delay)
|
|
158
|
+
|
|
159
|
+
def _attempt(self, url: str, body: bytes) -> None:
|
|
160
|
+
"""
|
|
161
|
+
Make one HTTP request.
|
|
162
|
+
|
|
163
|
+
:param url: where to post
|
|
164
|
+
:param body: the encoded batch
|
|
165
|
+
:return: nothing
|
|
166
|
+
:raises TransportError: on any HTTP or connection failure
|
|
167
|
+
"""
|
|
168
|
+
# The key is the only thing here that says who is calling. No
|
|
169
|
+
# header names an account: one that did would be an unauthenticated
|
|
170
|
+
# claim sitting next to the credential that actually proves it.
|
|
171
|
+
headers: Dict[str, str] = {
|
|
172
|
+
"Content-Type": "application/json",
|
|
173
|
+
"Authorization": f"Bearer {self.config.ingest_key}",
|
|
174
|
+
"User-Agent": f"convalesce-emit/{ceversio.__version__}",
|
|
175
|
+
}
|
|
176
|
+
# The endpoint is validated as http(s) in Config.validate.
|
|
177
|
+
request = urllib.request.Request( # nosec B310
|
|
178
|
+
url, data=body, method="POST", headers=headers
|
|
179
|
+
)
|
|
180
|
+
try:
|
|
181
|
+
with urllib.request.urlopen( # nosec B310
|
|
182
|
+
request, timeout=self.config.timeout
|
|
183
|
+
):
|
|
184
|
+
return
|
|
185
|
+
except urllib.error.HTTPError as exc:
|
|
186
|
+
raise ceerrors.TransportError(
|
|
187
|
+
f"HTTP {exc.code} from {url}", status=exc.code
|
|
188
|
+
) from exc
|
|
189
|
+
except urllib.error.URLError as exc:
|
|
190
|
+
raise ceerrors.TransportError(
|
|
191
|
+
f"could not reach {url}: {exc.reason}"
|
|
192
|
+
) from exc
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
def send_one(
|
|
196
|
+
*,
|
|
197
|
+
tool: str,
|
|
198
|
+
event: str,
|
|
199
|
+
payload: Any,
|
|
200
|
+
emitter: Optional[ceproto.EmitterLike] = None,
|
|
201
|
+
tool_version: Optional[str] = None,
|
|
202
|
+
) -> None:
|
|
203
|
+
"""
|
|
204
|
+
Send a single observation and flush, swallowing any failure.
|
|
205
|
+
|
|
206
|
+
The one-shot path plugins use, where events arrive singly from a hook
|
|
207
|
+
rather than in a stream worth batching.
|
|
208
|
+
|
|
209
|
+
:param tool: which tool produced this
|
|
210
|
+
:param event: which callback fired
|
|
211
|
+
:param payload: the tool's own output, untouched
|
|
212
|
+
:param emitter: emitter to send through; built from the environment when
|
|
213
|
+
not given
|
|
214
|
+
:param tool_version: the tool's version, where it could be read
|
|
215
|
+
:return: nothing
|
|
216
|
+
"""
|
|
217
|
+
try:
|
|
218
|
+
target = emitter or Emitter()
|
|
219
|
+
target.emit(
|
|
220
|
+
tool=tool, event=event, payload=payload, tool_version=tool_version
|
|
221
|
+
)
|
|
222
|
+
target.flush()
|
|
223
|
+
except Exception as exc: # pylint: disable=broad-exception-caught
|
|
224
|
+
# A customer's run must not fail because we could not report on it.
|
|
225
|
+
_LOG.warning("convalesce: could not emit %s: %s", event, exc)
|