UncountablePythonSDK 0.0.174__py3-none-any.whl → 0.0.175__py3-none-any.whl
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.
- pkgs/type_spec/non_discriminated_union_exceptions.py +1 -1
- uncountable/integration/telemetry.py +20 -31
- {uncountablepythonsdk-0.0.174.dist-info → uncountablepythonsdk-0.0.175.dist-info}/METADATA +1 -1
- {uncountablepythonsdk-0.0.174.dist-info → uncountablepythonsdk-0.0.175.dist-info}/RECORD +6 -6
- {uncountablepythonsdk-0.0.174.dist-info → uncountablepythonsdk-0.0.175.dist-info}/WHEEL +0 -0
- {uncountablepythonsdk-0.0.174.dist-info → uncountablepythonsdk-0.0.175.dist-info}/top_level.txt +0 -0
|
@@ -6,7 +6,7 @@ NON_DISCRIMINATED_UNION_EXCEPTIONS = [
|
|
|
6
6
|
"output_parameters.AnalyticalMethodLinkedOptionValue",
|
|
7
7
|
"recipes_redirect.RecipesRedirectResult",
|
|
8
8
|
"value_spec.ResolvedPathAll",
|
|
9
|
-
"
|
|
9
|
+
"deprecated_calculation_types.DeprecatedWeightedSumEntitiesV0",
|
|
10
10
|
"workflows.WorkflowTotalDisplay",
|
|
11
11
|
"type_info.TypeFormActionConstraint",
|
|
12
12
|
"structured_loading.CompatibleFilterNode",
|
|
@@ -15,7 +15,6 @@ from typing import Generator, assert_never, cast
|
|
|
15
15
|
import psutil
|
|
16
16
|
from opentelemetry import _logs, trace
|
|
17
17
|
from opentelemetry._logs import Logger as OTELLogger, LogRecord
|
|
18
|
-
from opentelemetry.context import get_current
|
|
19
18
|
from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter
|
|
20
19
|
from opentelemetry.sdk._logs import (
|
|
21
20
|
LoggerProvider,
|
|
@@ -51,23 +50,16 @@ def _cast_attributes(attributes: dict[str, base_t.JsonValue]) -> Attributes:
|
|
|
51
50
|
return cast(Attributes, attributes)
|
|
52
51
|
|
|
53
52
|
|
|
54
|
-
def _dd_log_correlation_attributes(
|
|
55
|
-
span_context: trace.SpanContext,
|
|
56
|
-
) -> dict[str, base_t.JsonValue]:
|
|
57
|
-
# Integration server logs export via ConsoleLogExporter
|
|
58
|
-
# (stdout), not OTLP, so we inject the dd.trace_id / dd.span_id
|
|
59
|
-
# correlation keys manually (hex trace, decimal span).
|
|
60
|
-
if not span_context.is_valid:
|
|
61
|
-
return {}
|
|
62
|
-
return {
|
|
63
|
-
"dd.trace_id": trace.format_trace_id(span_context.trace_id),
|
|
64
|
-
"dd.span_id": str(span_context.span_id),
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
|
|
68
53
|
def one_line_formatter(record: ReadableLogRecord) -> str:
|
|
69
|
-
|
|
70
|
-
|
|
54
|
+
payload = json.loads(record.to_json())
|
|
55
|
+
|
|
56
|
+
trace_id = record.log_record.trace_id
|
|
57
|
+
span_id = record.log_record.span_id
|
|
58
|
+
if trace_id:
|
|
59
|
+
payload["dd.trace_id"] = trace.format_trace_id(trace_id)
|
|
60
|
+
if span_id:
|
|
61
|
+
payload["dd.span_id"] = str(span_id)
|
|
62
|
+
return json.dumps(payload, separators=(",", ":")) + "\n"
|
|
71
63
|
|
|
72
64
|
|
|
73
65
|
@functools.cache
|
|
@@ -142,10 +134,10 @@ class Logger:
|
|
|
142
134
|
return self.base_span.get_span_context().span_id
|
|
143
135
|
|
|
144
136
|
@property
|
|
145
|
-
def
|
|
137
|
+
def trace_id(self) -> int | None:
|
|
146
138
|
return self.base_span.get_span_context().trace_id
|
|
147
139
|
|
|
148
|
-
def
|
|
140
|
+
def _current_span_with_fallback(self) -> Span:
|
|
149
141
|
active_span = trace.get_current_span()
|
|
150
142
|
if active_span.get_span_context().is_valid:
|
|
151
143
|
return active_span
|
|
@@ -158,7 +150,9 @@ class Logger:
|
|
|
158
150
|
message: str | None = None,
|
|
159
151
|
severity: LogSeverity | None = None,
|
|
160
152
|
) -> Attributes:
|
|
161
|
-
patched_attributes: dict[str, base_t.JsonValue] = {
|
|
153
|
+
patched_attributes: dict[str, base_t.JsonValue] = {
|
|
154
|
+
**self._bound_attributes,
|
|
155
|
+
}
|
|
162
156
|
for scope_attrs in self._scope_attributes_stack:
|
|
163
157
|
patched_attributes.update(scope_attrs)
|
|
164
158
|
if attributes is not None:
|
|
@@ -181,20 +175,15 @@ class Logger:
|
|
|
181
175
|
self, message: str, *, severity: LogSeverity, attributes: Attributes | None
|
|
182
176
|
) -> None:
|
|
183
177
|
otel_logger = get_otel_logger()
|
|
184
|
-
|
|
185
|
-
self._patch_attributes(
|
|
186
|
-
message=message, severity=severity, attributes=attributes
|
|
187
|
-
)
|
|
188
|
-
)
|
|
189
|
-
log_attributes.update(
|
|
190
|
-
_dd_log_correlation_attributes(self._correlation_span().get_span_context())
|
|
191
|
-
)
|
|
178
|
+
|
|
192
179
|
log_record = LogRecord(
|
|
193
180
|
body=message,
|
|
194
181
|
severity_text=severity,
|
|
195
182
|
timestamp=time.time_ns(),
|
|
196
|
-
attributes=
|
|
197
|
-
|
|
183
|
+
attributes=self._patch_attributes(
|
|
184
|
+
message=message, severity=severity, attributes=attributes
|
|
185
|
+
),
|
|
186
|
+
context=trace.set_span_in_context(self._current_span_with_fallback()),
|
|
198
187
|
severity_number=_get_severity_number(severity),
|
|
199
188
|
)
|
|
200
189
|
otel_logger.emit(log_record)
|
|
@@ -242,7 +231,7 @@ class Logger:
|
|
|
242
231
|
patched_attributes = self._patch_attributes(
|
|
243
232
|
message=message, severity=severity, attributes=attributes
|
|
244
233
|
)
|
|
245
|
-
self.
|
|
234
|
+
self._current_span_with_fallback().record_exception(
|
|
246
235
|
exception=exception, attributes=patched_attributes
|
|
247
236
|
)
|
|
248
237
|
log_message = f"{message}\nexception: {exception}{traceback_str}"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: UncountablePythonSDK
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.175
|
|
4
4
|
Summary: Uncountable SDK
|
|
5
5
|
Project-URL: Homepage, https://github.com/uncountableinc/uncountable-python-sdk
|
|
6
6
|
Project-URL: Repository, https://github.com/uncountableinc/uncountable-python-sdk.git
|
|
@@ -95,7 +95,7 @@ pkgs/type_spec/emit_python.py,sha256=zQXAw-vPbv-YCic5qXCebW5LhXTo9sUqwJ3d9aG48w4
|
|
|
95
95
|
pkgs/type_spec/emit_typescript.py,sha256=Qu9f1Yv_wc449KHcBGO58hatbzvPvgMbZ11jferi3oY,11567
|
|
96
96
|
pkgs/type_spec/emit_typescript_util.py,sha256=fNPgSMf3jA66_STGqN4cuH0rH3CvGLc3TKQIEdHxGYA,13558
|
|
97
97
|
pkgs/type_spec/load_types.py,sha256=1a8-AGVfpZTOiB8G-JW_1NhMZLg_SINaaKH6l2IrbW8,5045
|
|
98
|
-
pkgs/type_spec/non_discriminated_union_exceptions.py,sha256=
|
|
98
|
+
pkgs/type_spec/non_discriminated_union_exceptions.py,sha256=zfYHKhmq3Q7g6vB4tkno8pZj_F8enbSn_CjCJgJAu80,676
|
|
99
99
|
pkgs/type_spec/open_api_util.py,sha256=LX6ny4xNOWXQO3qWVM8elrSDTqWsj_7jFplax2POShE,7992
|
|
100
100
|
pkgs/type_spec/test.py,sha256=4ueujBq-pEgnX3Z69HyPmD-bullFXmpixcpVzfOkhP4,489
|
|
101
101
|
pkgs/type_spec/util.py,sha256=S_SGTJU192x-wIbngVUTvXhQENMbBfxluigLmnItGI8,4848
|
|
@@ -137,7 +137,7 @@ uncountable/integration/request_context.py,sha256=N_FJJxqvfUJ0yV9h3I3vFTGNJiDfyL
|
|
|
137
137
|
uncountable/integration/scan_profiles.py,sha256=iTpzYKBHarlhYG6CKYtyAmQ7vUhEUbj2icGVHell8AU,3059
|
|
138
138
|
uncountable/integration/scheduler.py,sha256=BajQ4txvgEBw8S9x1P0eGm-uBkKp_oecJK65SQd2hNw,8477
|
|
139
139
|
uncountable/integration/server.py,sha256=P4RRGwU9jMselHPWbU6GxhRLgVtN7Ydcxr18sFn2zI8,5778
|
|
140
|
-
uncountable/integration/telemetry.py,sha256=
|
|
140
|
+
uncountable/integration/telemetry.py,sha256=7IWhCxchtVYJwwwFYduwnMEUdxO8srx2RnocLzcQmtg,15965
|
|
141
141
|
uncountable/integration/db/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
142
142
|
uncountable/integration/db/connect.py,sha256=mE3bdV0huclH2iT_dXCQdRL4LkjIuf_myAR64RTWXEs,498
|
|
143
143
|
uncountable/integration/db/session.py,sha256=96cGQXpe6IugBTdSsjdP0S5yhJ6toSmbVB6qhc3FJzE,693
|
|
@@ -409,7 +409,7 @@ uncountable/types/api/uploader/complete_async_parse.py,sha256=Os1HAubxTlbut6Gylj
|
|
|
409
409
|
uncountable/types/api/uploader/invoke_uploader.py,sha256=QU1KmAFgGHSWskZEKfaAww8rCj-hVNP0i4kMQE3x3Fc,1822
|
|
410
410
|
uncountable/types/api/user/__init__.py,sha256=gCgbynxG3jA8FQHzercKtrHKHkiIKr8APdZYUniAor8,55
|
|
411
411
|
uncountable/types/api/user/get_current_user_info.py,sha256=BT7bGp5SOHz3XdKWhhdZ6acnInafT2PgdJ-H4YH3W7c,1181
|
|
412
|
-
uncountablepythonsdk-0.0.
|
|
413
|
-
uncountablepythonsdk-0.0.
|
|
414
|
-
uncountablepythonsdk-0.0.
|
|
415
|
-
uncountablepythonsdk-0.0.
|
|
412
|
+
uncountablepythonsdk-0.0.175.dist-info/METADATA,sha256=8pwGUT8NIoJ_bP3Y6TAOUjk8LSX_pDlAotlZC6UB4h0,2172
|
|
413
|
+
uncountablepythonsdk-0.0.175.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
|
|
414
|
+
uncountablepythonsdk-0.0.175.dist-info/top_level.txt,sha256=1UVGjAU-6hJY9qw2iJ7nCBeEwZ793AEN5ZfKX9A1uj4,31
|
|
415
|
+
uncountablepythonsdk-0.0.175.dist-info/RECORD,,
|
|
File without changes
|
{uncountablepythonsdk-0.0.174.dist-info → uncountablepythonsdk-0.0.175.dist-info}/top_level.txt
RENAMED
|
File without changes
|