atoti-client-observability 0.9.13__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.
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
|
+
Name: atoti-client-observability
|
|
3
|
+
Version: 0.9.13
|
|
4
|
+
Summary: Code to configure observability of Atoti sessions
|
|
5
|
+
Keywords: atoti,observability,opentelemetry
|
|
6
|
+
Author: ActiveViam
|
|
7
|
+
Author-email: ActiveViam <atoti-dev@activeviam.com>
|
|
8
|
+
Classifier: Development Status :: 4 - Beta
|
|
9
|
+
Classifier: License :: Free for non-commercial use
|
|
10
|
+
Classifier: Operating System :: OS Independent
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Typing :: Typed
|
|
13
|
+
Requires-Dist: atoti-client==0.9.13
|
|
14
|
+
Requires-Dist: atoti-core==0.9.13
|
|
15
|
+
Requires-Dist: pydantic>=2.12.3
|
|
16
|
+
Requires-Python: >=3.10
|
|
17
|
+
Project-URL: Documentation, https://docs.activeviam.com/products/atoti/python-sdk/0.9.13/api/atoti_observability.html
|
|
18
|
+
Project-URL: Homepage, https://www.atoti.io
|
|
19
|
+
Project-URL: Issues, https://github.com/atoti/atoti/issues
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
atoti_observability/__init__.py,sha256=u1tC0_Xj-cbE7t4rh-StLolfYxrvhAFGKcunW4tk6tM,6724
|
|
2
|
+
atoti_observability/observability_config.py,sha256=mmdRL7dOTEF2lXURb-ZjADXv1x0H44M1UdlCEp0Y42c,513
|
|
3
|
+
atoti_observability/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
|
+
atoti_client_observability-0.9.13.dist-info/WHEEL,sha256=mydTeHxOpFHo-DnYhAd_3ATePms-g4rrYvM7wJK8P-U,80
|
|
5
|
+
atoti_client_observability-0.9.13.dist-info/METADATA,sha256=ZoBPt6NJBsYqJoCfFvysi9TGNHTxy1f8ylDnsUQxZCc,809
|
|
6
|
+
atoti_client_observability-0.9.13.dist-info/RECORD,,
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
"""Plugin enhancing observability of Atoti sessions.
|
|
2
|
+
|
|
3
|
+
Projects using Atoti Python SDK will have this kind of architecture:
|
|
4
|
+
|
|
5
|
+
.. raw:: html
|
|
6
|
+
|
|
7
|
+
<div class="mermaid">
|
|
8
|
+
flowchart LR
|
|
9
|
+
upstream["Upstream service"]
|
|
10
|
+
style upstream stroke-dasharray: 5 5
|
|
11
|
+
|
|
12
|
+
subgraph python["Python application"]
|
|
13
|
+
atoti-python-sdk["Atoti Python SDK"]
|
|
14
|
+
other-libs["Other third-party libraries"]
|
|
15
|
+
style other-libs stroke-dasharray: 5 5
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
atoti-server["Atoti Server"]
|
|
19
|
+
other-services["Other services"]
|
|
20
|
+
style other-services stroke-dasharray: 5 5
|
|
21
|
+
|
|
22
|
+
upstream -.-> python
|
|
23
|
+
atoti-python-sdk --> atoti-server
|
|
24
|
+
other-libs -.-> other-services
|
|
25
|
+
</div>
|
|
26
|
+
|
|
27
|
+
OpenTelemetry distributed tracing allows these different services to contribute their own spans to the same trace.
|
|
28
|
+
This makes it possible to follow a request across process boundaries, identify bottlenecks, and understand the end-to-end latency of operations.
|
|
29
|
+
|
|
30
|
+
With this plugin enabled, Atoti Server will also expose :atoti_server_docs:`some metrics <monitoring/metrics/#metrics-available>` through OpenTelemetry.
|
|
31
|
+
|
|
32
|
+
A quick way to get started with observability is to:
|
|
33
|
+
|
|
34
|
+
#. Run a `Jaeger all-in-one Docker container <https://www.jaegertracing.io/docs/2.16/getting-started/#all-in-one>`__ (or any other OpenTelemetry collector).
|
|
35
|
+
#. Install `one of the Python OpenTelemetry exporters <https://opentelemetry.io/docs/languages/python/exporters/#otlp-dependencies>`__.
|
|
36
|
+
#. Install :mod:`atoti-observability <atoti_observability>` (this plugin).
|
|
37
|
+
#. Call ``opentelemetry.trace.set_tracer_provider()`` at the start of the Python application.
|
|
38
|
+
#. Create spans in the application code for each major step.
|
|
39
|
+
|
|
40
|
+
Note:
|
|
41
|
+
When using different ports than the OpenTelemetry's default ones, do not forget to set ``os.environ["OTEL_EXPORTER_OTLP_ENDPOINT"]`` before calling :meth:`atoti.Session.start` so that the Atoti Server launched in a subprocess inherits it and exports its telemetry data to the right place.
|
|
42
|
+
|
|
43
|
+
Tip:
|
|
44
|
+
This plugin automatically adds the `OpenTelemetry Java agent <https://opentelemetry.io/docs/zero-code/java/agent/>`__ to the server process but this can be changed by passing another ``-javaagent:*`` to the :attr:`~atoti.SessionConfig.java_options`.
|
|
45
|
+
|
|
46
|
+
Example:
|
|
47
|
+
.. doctest::
|
|
48
|
+
:hide:
|
|
49
|
+
|
|
50
|
+
>>> jaeger_client = getfixture("jaeger_client")
|
|
51
|
+
>>> from test_utils import (
|
|
52
|
+
... get_session_with_plugin_fixture_name,
|
|
53
|
+
... span_tree_from_trace,
|
|
54
|
+
... )
|
|
55
|
+
>>> session = getfixture("default_session")
|
|
56
|
+
>>> session_with_observability_plugin = getfixture(
|
|
57
|
+
... get_session_with_plugin_fixture_name("observability")
|
|
58
|
+
... )
|
|
59
|
+
|
|
60
|
+
Here, the OpenTelemetry environment is already configured:
|
|
61
|
+
|
|
62
|
+
>>> import os
|
|
63
|
+
>>> from opentelemetry.sdk.environment_variables import OTEL_EXPORTER_OTLP_ENDPOINT
|
|
64
|
+
>>> OTEL_EXPORTER_OTLP_ENDPOINT in os.environ
|
|
65
|
+
True
|
|
66
|
+
|
|
67
|
+
Creating a tracer for this example (usually an application would use the same tracer for all its spans):
|
|
68
|
+
|
|
69
|
+
>>> from opentelemetry.trace import get_tracer
|
|
70
|
+
>>> tracer = get_tracer("example")
|
|
71
|
+
|
|
72
|
+
Creating a simple trace with multiple spans:
|
|
73
|
+
|
|
74
|
+
>>> with tracer.start_as_current_span("root") as root_span:
|
|
75
|
+
... foo = 1
|
|
76
|
+
... with tracer.start_as_current_span("intermediate"):
|
|
77
|
+
... bar = 2
|
|
78
|
+
... with tracer.start_as_current_span("leaf"):
|
|
79
|
+
... baz = 3
|
|
80
|
+
|
|
81
|
+
.. doctest::
|
|
82
|
+
:hide:
|
|
83
|
+
|
|
84
|
+
>>> trace_id = root_span.get_span_context().trace_id
|
|
85
|
+
>>> trace, _ = jaeger_client.fetch_trace_with_spans(trace_id)
|
|
86
|
+
>>> span_tree = span_tree_from_trace(trace)
|
|
87
|
+
|
|
88
|
+
>>> print(span_tree)
|
|
89
|
+
⏺ root [atoti.python_sdk.tests]
|
|
90
|
+
└── intermediate [atoti.python_sdk.tests]
|
|
91
|
+
└── leaf [atoti.python_sdk.tests]
|
|
92
|
+
|
|
93
|
+
With some spans contributed by Atoti Python SDK:
|
|
94
|
+
|
|
95
|
+
>>> def _create_trace(session: tt.Session, /) -> int:
|
|
96
|
+
... cities_df = pd.DataFrame(
|
|
97
|
+
... columns=["City", "Price"],
|
|
98
|
+
... data=[
|
|
99
|
+
... ("Berlin", 150.0),
|
|
100
|
+
... ("London", 240.0),
|
|
101
|
+
... ("New York", 270.0),
|
|
102
|
+
... ("Paris", 200.0),
|
|
103
|
+
... ],
|
|
104
|
+
... )
|
|
105
|
+
... table = session.read_pandas(cities_df, keys={"City"}, table_name="Example")
|
|
106
|
+
... cube = session.create_cube(table)
|
|
107
|
+
... level = cube.levels["City"]
|
|
108
|
+
... measure = cube.measures["Price.SUM"]
|
|
109
|
+
... with tracer.start_as_current_span("query") as root_span:
|
|
110
|
+
... _ = cube.query(measure, levels=[level])
|
|
111
|
+
... return root_span
|
|
112
|
+
>>> root_span = _create_trace(session)
|
|
113
|
+
|
|
114
|
+
.. doctest::
|
|
115
|
+
:hide:
|
|
116
|
+
|
|
117
|
+
>>> trace_id = root_span.get_span_context().trace_id
|
|
118
|
+
>>> expected_span_names = "cellset_to_mdx_query_result", "generate_mdx"
|
|
119
|
+
>>> trace, _ = jaeger_client.fetch_trace_with_spans(
|
|
120
|
+
... trace_id, *expected_span_names
|
|
121
|
+
... )
|
|
122
|
+
>>> span_tree = span_tree_from_trace(trace)
|
|
123
|
+
|
|
124
|
+
>>> print(span_tree)
|
|
125
|
+
⏺ query [atoti.python_sdk.tests]
|
|
126
|
+
├── generate_mdx [atoti.python_sdk.tests]
|
|
127
|
+
└── cellset_to_mdx_query_result [atoti.python_sdk.tests]
|
|
128
|
+
|
|
129
|
+
The server spans can be seen when using a session with the observability plugin enabled:
|
|
130
|
+
|
|
131
|
+
>>> root_span = _create_trace(session_with_observability_plugin)
|
|
132
|
+
|
|
133
|
+
.. doctest::
|
|
134
|
+
:hide:
|
|
135
|
+
|
|
136
|
+
>>> trace_id = root_span.get_span_context().trace_id
|
|
137
|
+
>>> expected_span_names = (*expected_span_names, "Database query")
|
|
138
|
+
>>> trace, _ = jaeger_client.fetch_trace_with_spans(
|
|
139
|
+
... trace_id, *expected_span_names
|
|
140
|
+
... )
|
|
141
|
+
>>> span_tree = span_tree_from_trace(
|
|
142
|
+
... trace,
|
|
143
|
+
... ignored_span_names={"entry retrieval", "stored files retrieval"},
|
|
144
|
+
... )
|
|
145
|
+
|
|
146
|
+
>>> print(span_tree)
|
|
147
|
+
⏺ query [atoti.python_sdk.tests]
|
|
148
|
+
├── GET /activeviam/pivot/rest/v10/cube/discovery [atoti.server]
|
|
149
|
+
├── generate_mdx [atoti.python_sdk.tests]
|
|
150
|
+
├── POST /activeviam/pivot/rest/v10/cube/query/mdx [atoti.server]
|
|
151
|
+
│ └── Json query service [atoti.server]
|
|
152
|
+
│ └── select query [atoti.server]
|
|
153
|
+
│ └── Async query executor [atoti.server]
|
|
154
|
+
│ └── just-in-time query [atoti.server]
|
|
155
|
+
│ └── Database query [atoti.server]
|
|
156
|
+
└── cellset_to_mdx_query_result [atoti.python_sdk.tests]
|
|
157
|
+
├── POST /graphql [atoti.server]
|
|
158
|
+
│ └── query [atoti.server]
|
|
159
|
+
└── POST /graphql [atoti.server]
|
|
160
|
+
└── query [atoti.server]
|
|
161
|
+
|
|
162
|
+
"""
|
|
163
|
+
|
|
164
|
+
from .observability_config import ObservabilityConfig as ObservabilityConfig
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from typing import final
|
|
4
|
+
|
|
5
|
+
from _atoti_core import (
|
|
6
|
+
DEFAULT_ATOTI_SERVER_OTEL_SERVICE_NAME as _DEFAULT_ATOTI_SERVER_OTEL_SERVICE_NAME,
|
|
7
|
+
)
|
|
8
|
+
from atoti._pydantic import PYDANTIC_CONFIG as _PYDANTIC_CONFIG
|
|
9
|
+
from pydantic.dataclasses import dataclass
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
@final
|
|
13
|
+
@dataclass(config=_PYDANTIC_CONFIG, frozen=True, kw_only=True)
|
|
14
|
+
class ObservabilityConfig:
|
|
15
|
+
server_service_name: str = _DEFAULT_ATOTI_SERVER_OTEL_SERVICE_NAME
|
|
16
|
+
"""The OpenTelemetry service name for Atoti server."""
|
|
File without changes
|