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.
Files changed (44) hide show
  1. encore/__init__.py +43 -0
  2. encore/cron/__init__.py +50 -0
  3. encore/internal/__init__.py +1 -0
  4. encore/internal/_loader.py +79 -0
  5. encore/internal/_native.pyi +734 -0
  6. encore/internal/lazy.py +35 -0
  7. encore/internal/runtime.py +133 -0
  8. encore/internal/startup.py +24 -0
  9. encore/logs/__init__.py +19 -0
  10. encore/logs/_console.py +155 -0
  11. encore/logs/_runtime.py +56 -0
  12. encore/meta/__init__.py +228 -0
  13. encore/metrics/__init__.py +390 -0
  14. encore/pubsub/__init__.py +425 -0
  15. encore/py.typed +0 -0
  16. encore/secrets/__init__.py +139 -0
  17. encore/shutdown/__init__.py +164 -0
  18. encore/storage/__init__.py +5 -0
  19. encore/storage/objects/__init__.py +396 -0
  20. encore/storage/postgres/__init__.py +737 -0
  21. encore/storage/redis/__init__.py +200 -0
  22. encore/storage/redis/_base.py +42 -0
  23. encore/storage/redis/_responses.py +150 -0
  24. encore/storage/redis/_values.py +189 -0
  25. encore/storage/redis/bitmap.py +142 -0
  26. encore/storage/redis/generic.py +367 -0
  27. encore/storage/redis/geo.py +508 -0
  28. encore/storage/redis/hash.py +504 -0
  29. encore/storage/redis/json.py +614 -0
  30. encore/storage/redis/list.py +511 -0
  31. encore/storage/redis/pubsub.py +276 -0
  32. encore/storage/redis/set.py +570 -0
  33. encore/storage/redis/sorted_set.py +753 -0
  34. encore/storage/redis/stream.py +773 -0
  35. encore/storage/redis/string.py +654 -0
  36. encore/tracing/__init__.py +19 -0
  37. encore/tracing/_context.py +27 -0
  38. encore/tracing/_encode.py +351 -0
  39. encore/tracing/_provider.py +62 -0
  40. encore/tracing/_span.py +226 -0
  41. encore/tracing/_tracer.py +93 -0
  42. encore_dev-2.0.0a7.dist-info/METADATA +791 -0
  43. encore_dev-2.0.0a7.dist-info/RECORD +44 -0
  44. 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