encore-dev 2.0.0a7__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.
- encore/__init__.py +43 -0
- encore/cron/__init__.py +50 -0
- encore/internal/__init__.py +1 -0
- encore/internal/_loader.py +79 -0
- encore/internal/_native.pyi +734 -0
- encore/internal/lazy.py +35 -0
- encore/internal/runtime.py +133 -0
- encore/internal/startup.py +24 -0
- encore/logs/__init__.py +19 -0
- encore/logs/_console.py +155 -0
- encore/logs/_runtime.py +56 -0
- encore/meta/__init__.py +228 -0
- encore/metrics/__init__.py +390 -0
- encore/pubsub/__init__.py +425 -0
- encore/py.typed +0 -0
- encore/secrets/__init__.py +139 -0
- encore/shutdown/__init__.py +164 -0
- encore/storage/__init__.py +5 -0
- encore/storage/objects/__init__.py +396 -0
- encore/storage/postgres/__init__.py +737 -0
- encore/storage/redis/__init__.py +200 -0
- encore/storage/redis/_base.py +42 -0
- encore/storage/redis/_responses.py +150 -0
- encore/storage/redis/_values.py +189 -0
- encore/storage/redis/bitmap.py +142 -0
- encore/storage/redis/generic.py +367 -0
- encore/storage/redis/geo.py +508 -0
- encore/storage/redis/hash.py +504 -0
- encore/storage/redis/json.py +614 -0
- encore/storage/redis/list.py +511 -0
- encore/storage/redis/pubsub.py +276 -0
- encore/storage/redis/set.py +570 -0
- encore/storage/redis/sorted_set.py +753 -0
- encore/storage/redis/stream.py +773 -0
- encore/storage/redis/string.py +654 -0
- encore/tracing/__init__.py +19 -0
- encore/tracing/_context.py +27 -0
- encore/tracing/_encode.py +351 -0
- encore/tracing/_provider.py +62 -0
- encore/tracing/_span.py +226 -0
- encore/tracing/_tracer.py +93 -0
- encore_dev-2.0.0a7.dist-info/METADATA +791 -0
- encore_dev-2.0.0a7.dist-info/RECORD +44 -0
- encore_dev-2.0.0a7.dist-info/WHEEL +4 -0
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"""An ``opentelemetry.trace.Tracer`` backed by the runtime's pipeline."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import Iterator, Optional, Sequence
|
|
6
|
+
|
|
7
|
+
from opentelemetry import context as context_api
|
|
8
|
+
from opentelemetry import trace
|
|
9
|
+
from opentelemetry.trace import Link, SpanKind
|
|
10
|
+
from opentelemetry.util import types
|
|
11
|
+
from opentelemetry.util._decorator import _agnosticcontextmanager
|
|
12
|
+
|
|
13
|
+
from ._context import span_ctx_bytes
|
|
14
|
+
from ._encode import Scope, encode_start
|
|
15
|
+
from ._span import Backend, Span
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class Tracer(trace.Tracer):
|
|
19
|
+
"""A tracer whose spans share an instrumentation scope.
|
|
20
|
+
|
|
21
|
+
The runtime assigns span identifiers and timestamps.
|
|
22
|
+
"""
|
|
23
|
+
|
|
24
|
+
def __init__(self, backend: Backend, scope: Scope) -> None:
|
|
25
|
+
self._backend = backend
|
|
26
|
+
self._scope = scope
|
|
27
|
+
|
|
28
|
+
def start_span(
|
|
29
|
+
self,
|
|
30
|
+
name: str,
|
|
31
|
+
context: Optional[context_api.Context] = None,
|
|
32
|
+
kind: SpanKind = SpanKind.INTERNAL,
|
|
33
|
+
attributes: types.Attributes = None,
|
|
34
|
+
links: Optional[Sequence[Link]] = None,
|
|
35
|
+
start_time: Optional[int] = None,
|
|
36
|
+
record_exception: bool = True,
|
|
37
|
+
set_status_on_exception: bool = True,
|
|
38
|
+
) -> trace.Span:
|
|
39
|
+
parent = trace.get_current_span(context)
|
|
40
|
+
parent_ctx = parent.get_span_context()
|
|
41
|
+
parent_bytes = span_ctx_bytes(parent) if parent_ctx.is_valid else None
|
|
42
|
+
ctx, tracestate, start_unix, start_mono = self._backend.start_span(
|
|
43
|
+
name,
|
|
44
|
+
kind.value,
|
|
45
|
+
parent_bytes,
|
|
46
|
+
parent_ctx.trace_state.to_header() if parent_bytes else None,
|
|
47
|
+
start_time,
|
|
48
|
+
encode_start(self._scope, attributes, links),
|
|
49
|
+
)
|
|
50
|
+
return Span(
|
|
51
|
+
backend=self._backend,
|
|
52
|
+
scope=self._scope,
|
|
53
|
+
ctx_bytes=ctx,
|
|
54
|
+
tracestate=tracestate,
|
|
55
|
+
name=name,
|
|
56
|
+
kind=kind,
|
|
57
|
+
parent_span_id=parent_bytes[16:24] if parent_bytes else None,
|
|
58
|
+
start_unix_nanos=start_unix,
|
|
59
|
+
start_mono_nanos=start_mono,
|
|
60
|
+
attributes=attributes,
|
|
61
|
+
links=links,
|
|
62
|
+
)
|
|
63
|
+
|
|
64
|
+
@_agnosticcontextmanager
|
|
65
|
+
def start_as_current_span(
|
|
66
|
+
self,
|
|
67
|
+
name: str,
|
|
68
|
+
context: Optional[context_api.Context] = None,
|
|
69
|
+
kind: SpanKind = SpanKind.INTERNAL,
|
|
70
|
+
attributes: types.Attributes = None,
|
|
71
|
+
links: Optional[Sequence[Link]] = None,
|
|
72
|
+
start_time: Optional[int] = None,
|
|
73
|
+
record_exception: bool = True,
|
|
74
|
+
set_status_on_exception: bool = True,
|
|
75
|
+
end_on_exit: bool = True,
|
|
76
|
+
) -> Iterator[trace.Span]:
|
|
77
|
+
span = self.start_span(
|
|
78
|
+
name,
|
|
79
|
+
context,
|
|
80
|
+
kind,
|
|
81
|
+
attributes,
|
|
82
|
+
links,
|
|
83
|
+
start_time,
|
|
84
|
+
record_exception,
|
|
85
|
+
set_status_on_exception,
|
|
86
|
+
)
|
|
87
|
+
with trace.use_span(
|
|
88
|
+
span,
|
|
89
|
+
end_on_exit=end_on_exit,
|
|
90
|
+
record_exception=record_exception,
|
|
91
|
+
set_status_on_exception=set_status_on_exception,
|
|
92
|
+
) as s:
|
|
93
|
+
yield s
|