warpzone-sdk 15.0.0.dev13__tar.gz → 15.0.1.dev1__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.
- {warpzone_sdk-15.0.0.dev13 → warpzone_sdk-15.0.1.dev1}/PKG-INFO +1 -1
- {warpzone_sdk-15.0.0.dev13 → warpzone_sdk-15.0.1.dev1}/pyproject.toml +1 -1
- {warpzone_sdk-15.0.0.dev13 → warpzone_sdk-15.0.1.dev1}/warpzone/db/client.py +63 -13
- {warpzone_sdk-15.0.0.dev13 → warpzone_sdk-15.0.1.dev1}/warpzone/function/integrations.py +1 -1
- {warpzone_sdk-15.0.0.dev13 → warpzone_sdk-15.0.1.dev1}/warpzone/function/monitor.py +0 -10
- {warpzone_sdk-15.0.0.dev13 → warpzone_sdk-15.0.1.dev1}/warpzone/monitor/logs.py +31 -27
- {warpzone_sdk-15.0.0.dev13 → warpzone_sdk-15.0.1.dev1}/warpzone/monitor/traces.py +37 -26
- {warpzone_sdk-15.0.0.dev13 → warpzone_sdk-15.0.1.dev1}/warpzone/tablestorage/db/client.py +15 -27
- {warpzone_sdk-15.0.0.dev13 → warpzone_sdk-15.0.1.dev1}/README.md +0 -0
- {warpzone_sdk-15.0.0.dev13 → warpzone_sdk-15.0.1.dev1}/warpzone/__init__.py +0 -0
- {warpzone_sdk-15.0.0.dev13 → warpzone_sdk-15.0.1.dev1}/warpzone/blobstorage/__init__.py +0 -0
- {warpzone_sdk-15.0.0.dev13 → warpzone_sdk-15.0.1.dev1}/warpzone/blobstorage/client.py +0 -0
- {warpzone_sdk-15.0.0.dev13 → warpzone_sdk-15.0.1.dev1}/warpzone/db/__init__.py +0 -0
- {warpzone_sdk-15.0.0.dev13 → warpzone_sdk-15.0.1.dev1}/warpzone/deltastorage/__init__.py +0 -0
- {warpzone_sdk-15.0.0.dev13 → warpzone_sdk-15.0.1.dev1}/warpzone/deltastorage/data_types.py +0 -0
- {warpzone_sdk-15.0.0.dev13 → warpzone_sdk-15.0.1.dev1}/warpzone/deltastorage/generated_columns.py +0 -0
- {warpzone_sdk-15.0.0.dev13 → warpzone_sdk-15.0.1.dev1}/warpzone/deltastorage/lock_client.py +0 -0
- {warpzone_sdk-15.0.0.dev13 → warpzone_sdk-15.0.1.dev1}/warpzone/deltastorage/schema.py +0 -0
- {warpzone_sdk-15.0.0.dev13 → warpzone_sdk-15.0.1.dev1}/warpzone/deltastorage/slicing.py +0 -0
- {warpzone_sdk-15.0.0.dev13 → warpzone_sdk-15.0.1.dev1}/warpzone/deltastorage/store.py +0 -0
- {warpzone_sdk-15.0.0.dev13 → warpzone_sdk-15.0.1.dev1}/warpzone/deltastorage/table.py +0 -0
- {warpzone_sdk-15.0.0.dev13 → warpzone_sdk-15.0.1.dev1}/warpzone/enums/__init__.py +0 -0
- {warpzone_sdk-15.0.0.dev13 → warpzone_sdk-15.0.1.dev1}/warpzone/enums/topicenum.py +0 -0
- {warpzone_sdk-15.0.0.dev13 → warpzone_sdk-15.0.1.dev1}/warpzone/function/__init__.py +0 -0
- {warpzone_sdk-15.0.0.dev13 → warpzone_sdk-15.0.1.dev1}/warpzone/function/checks.py +0 -0
- {warpzone_sdk-15.0.0.dev13 → warpzone_sdk-15.0.1.dev1}/warpzone/function/functionize.py +0 -0
- {warpzone_sdk-15.0.0.dev13 → warpzone_sdk-15.0.1.dev1}/warpzone/function/process.py +0 -0
- {warpzone_sdk-15.0.0.dev13 → warpzone_sdk-15.0.1.dev1}/warpzone/function/processors/__init__.py +0 -0
- {warpzone_sdk-15.0.0.dev13 → warpzone_sdk-15.0.1.dev1}/warpzone/function/processors/dependencies.py +0 -0
- {warpzone_sdk-15.0.0.dev13 → warpzone_sdk-15.0.1.dev1}/warpzone/function/processors/outputs.py +0 -0
- {warpzone_sdk-15.0.0.dev13 → warpzone_sdk-15.0.1.dev1}/warpzone/function/processors/triggers.py +0 -0
- {warpzone_sdk-15.0.0.dev13 → warpzone_sdk-15.0.1.dev1}/warpzone/function/signature.py +0 -0
- {warpzone_sdk-15.0.0.dev13 → warpzone_sdk-15.0.1.dev1}/warpzone/function/types.py +0 -0
- {warpzone_sdk-15.0.0.dev13 → warpzone_sdk-15.0.1.dev1}/warpzone/healthchecks/__init__.py +0 -0
- {warpzone_sdk-15.0.0.dev13 → warpzone_sdk-15.0.1.dev1}/warpzone/healthchecks/model.py +0 -0
- {warpzone_sdk-15.0.0.dev13 → warpzone_sdk-15.0.1.dev1}/warpzone/monitor/__init__.py +0 -0
- {warpzone_sdk-15.0.0.dev13 → warpzone_sdk-15.0.1.dev1}/warpzone/servicebus/data/__init__.py +0 -0
- {warpzone_sdk-15.0.0.dev13 → warpzone_sdk-15.0.1.dev1}/warpzone/servicebus/data/client.py +0 -0
- {warpzone_sdk-15.0.0.dev13 → warpzone_sdk-15.0.1.dev1}/warpzone/servicebus/events/__init__.py +0 -0
- {warpzone_sdk-15.0.0.dev13 → warpzone_sdk-15.0.1.dev1}/warpzone/servicebus/events/client.py +0 -0
- {warpzone_sdk-15.0.0.dev13 → warpzone_sdk-15.0.1.dev1}/warpzone/servicebus/events/triggers.py +0 -0
- {warpzone_sdk-15.0.0.dev13 → warpzone_sdk-15.0.1.dev1}/warpzone/tablestorage/db/__init__.py +0 -0
- {warpzone_sdk-15.0.0.dev13 → warpzone_sdk-15.0.1.dev1}/warpzone/tablestorage/db/base_client.py +0 -0
- {warpzone_sdk-15.0.0.dev13 → warpzone_sdk-15.0.1.dev1}/warpzone/tablestorage/db/table_config.py +0 -0
- {warpzone_sdk-15.0.0.dev13 → warpzone_sdk-15.0.1.dev1}/warpzone/tablestorage/tables/__init__.py +0 -0
- {warpzone_sdk-15.0.0.dev13 → warpzone_sdk-15.0.1.dev1}/warpzone/tablestorage/tables/client.py +0 -0
- {warpzone_sdk-15.0.0.dev13 → warpzone_sdk-15.0.1.dev1}/warpzone/tablestorage/tables/entities.py +0 -0
- {warpzone_sdk-15.0.0.dev13 → warpzone_sdk-15.0.1.dev1}/warpzone/tablestorage/tables/helpers.py +0 -0
- {warpzone_sdk-15.0.0.dev13 → warpzone_sdk-15.0.1.dev1}/warpzone/testing/__init__.py +0 -0
- {warpzone_sdk-15.0.0.dev13 → warpzone_sdk-15.0.1.dev1}/warpzone/testing/assertions.py +0 -0
- {warpzone_sdk-15.0.0.dev13 → warpzone_sdk-15.0.1.dev1}/warpzone/testing/data.py +0 -0
- {warpzone_sdk-15.0.0.dev13 → warpzone_sdk-15.0.1.dev1}/warpzone/testing/matchers.py +0 -0
- {warpzone_sdk-15.0.0.dev13 → warpzone_sdk-15.0.1.dev1}/warpzone/tools/__init__.py +0 -0
- {warpzone_sdk-15.0.0.dev13 → warpzone_sdk-15.0.1.dev1}/warpzone/tools/copy.py +0 -0
- {warpzone_sdk-15.0.0.dev13 → warpzone_sdk-15.0.1.dev1}/warpzone/transform/__init__.py +0 -0
- {warpzone_sdk-15.0.0.dev13 → warpzone_sdk-15.0.1.dev1}/warpzone/transform/data.py +0 -0
- {warpzone_sdk-15.0.0.dev13 → warpzone_sdk-15.0.1.dev1}/warpzone/transform/schema.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: warpzone-sdk
|
|
3
|
-
Version: 15.0.
|
|
3
|
+
Version: 15.0.1.dev1
|
|
4
4
|
Summary: The main objective of this package is to centralize logic used to interact with Azure Functions, Azure Service Bus and Azure Table Storage
|
|
5
5
|
Author: Team Enigma
|
|
6
6
|
Author-email: enigma@energinet.dk
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "warpzone-sdk"
|
|
3
|
-
version = "15.0.
|
|
3
|
+
version = "15.0.1.dev1"
|
|
4
4
|
description = "The main objective of this package is to centralize logic used to interact with Azure Functions, Azure Service Bus and Azure Table Storage"
|
|
5
5
|
authors = [{ name = "Team Enigma", email = "enigma@energinet.dk" }]
|
|
6
6
|
requires-python = ">=3.10"
|
|
@@ -32,29 +32,51 @@ class WarpzoneDatabaseClient:
|
|
|
32
32
|
self,
|
|
33
33
|
path: str,
|
|
34
34
|
storage_options: dict[str, str] | None = None,
|
|
35
|
+
table_prefix: str = "",
|
|
35
36
|
):
|
|
36
37
|
self.store = Store(
|
|
37
38
|
path=path,
|
|
38
39
|
storage_options=storage_options,
|
|
39
40
|
)
|
|
41
|
+
self.table_prefix = table_prefix
|
|
40
42
|
|
|
41
43
|
@classmethod
|
|
42
|
-
def
|
|
44
|
+
def from_resource_name(
|
|
43
45
|
cls,
|
|
44
46
|
storage_account: str,
|
|
45
47
|
container_name: str = "datasets",
|
|
48
|
+
sub_path: str = "",
|
|
49
|
+
table_prefix: str = "",
|
|
46
50
|
credential: (
|
|
47
51
|
AzureNamedKeyCredential | AzureSasCredential | TokenCredential
|
|
48
52
|
) = DefaultAzureCredential(),
|
|
49
53
|
):
|
|
54
|
+
"""Create a WarpzoneDatabaseClient from resource name (storage account).
|
|
55
|
+
This assumes the path of the delta lake is of the form:
|
|
56
|
+
abfss://{container_name}@{storage_account}.dfs.core.windows.net/{sub_path}
|
|
57
|
+
|
|
58
|
+
Args:
|
|
59
|
+
storage_account (str): Storage account name.
|
|
60
|
+
container_name (str, optional): Container name. Defaults to "datasets".
|
|
61
|
+
sub_path (str, optional): Sub-path within the container. Defaults to "".
|
|
62
|
+
table_prefix (str, optional): Table prefix to use (e.g. `mz_` for archive).
|
|
63
|
+
Defaults to "".
|
|
64
|
+
credential (optional): Azure credential to use.
|
|
65
|
+
Defaults to DefaultAzureCredential().
|
|
66
|
+
"""
|
|
50
67
|
path = f"abfss://{container_name}@{storage_account}.dfs.core.windows.net"
|
|
68
|
+
if sub_path:
|
|
69
|
+
path += f"/{sub_path}"
|
|
70
|
+
|
|
51
71
|
token = credential.get_token("https://storage.azure.com/.default")
|
|
52
72
|
storage_options = {
|
|
53
73
|
"account_name": storage_account,
|
|
54
74
|
"token": token.token,
|
|
55
75
|
}
|
|
56
76
|
|
|
57
|
-
return cls(
|
|
77
|
+
return cls(
|
|
78
|
+
path=path, storage_options=storage_options, table_prefix=table_prefix
|
|
79
|
+
)
|
|
58
80
|
|
|
59
81
|
def get_unit_and_multiple(self, timedelta: pd.Timedelta) -> tuple[str | None, int]:
|
|
60
82
|
"""
|
|
@@ -148,7 +170,35 @@ class WarpzoneDatabaseClient:
|
|
|
148
170
|
time_interval: Optional[pdz.TimeInterval] = None,
|
|
149
171
|
time_travel: Optional[pdz.TimeTravel] = None,
|
|
150
172
|
filters: Optional[dict[str, object]] = None,
|
|
173
|
+
include_validity_period_columns: bool = False,
|
|
174
|
+
include_generated_columns: bool = False,
|
|
151
175
|
) -> pd.DataFrame:
|
|
176
|
+
"""Query table.
|
|
177
|
+
Query defaults are set to match old Table Storage client behavior.
|
|
178
|
+
Time travel defaults to "as of now"
|
|
179
|
+
Validity period columns are dropped by default.
|
|
180
|
+
Generated columns are dropped by default.
|
|
181
|
+
|
|
182
|
+
Args:
|
|
183
|
+
table_name (str): Name of the table
|
|
184
|
+
time_interval (Optional[pdz.TimeInterval], optional): Time interval for the
|
|
185
|
+
query. Defaults to None.
|
|
186
|
+
time_travel (Optional[pdz.TimeTravel], optional): Time travel information.
|
|
187
|
+
Defaults to None.
|
|
188
|
+
filters (Optional[dict[str, object]], optional): Filters to apply to the
|
|
189
|
+
query.
|
|
190
|
+
Defaults to None.
|
|
191
|
+
include_validity_period_columns (bool, optional): Whether to include
|
|
192
|
+
validity period columns in the result;
|
|
193
|
+
(e.g. `valid_from_time_utc`, `valid_to_time_utc`).
|
|
194
|
+
Defaults to False.
|
|
195
|
+
include_generated_columns (bool, optional): Whether to include generated
|
|
196
|
+
columns in the result; (e.g. `valid_from_time_utc`, `valid_to_time_utc`).
|
|
197
|
+
Defaults to False.
|
|
198
|
+
|
|
199
|
+
Returns:
|
|
200
|
+
pd.DataFrame: The result of the query.
|
|
201
|
+
"""
|
|
152
202
|
# We do 'camelCaseToSnake_case' conversion here because the old
|
|
153
203
|
# naming convention used in WarpZone was CamelCase, while the new
|
|
154
204
|
# naming convention is snake_case. The goal is to remove this
|
|
@@ -191,16 +241,16 @@ class WarpzoneDatabaseClient:
|
|
|
191
241
|
for col in pd_df.select_dtypes(include=["datetime", "datetimetz"]).columns:
|
|
192
242
|
pd_df[col] = pd_df[col].dt.floor("s").dt.as_unit("ns")
|
|
193
243
|
|
|
194
|
-
#
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
244
|
+
# Drop generated columns
|
|
245
|
+
if not include_generated_columns:
|
|
246
|
+
generated_cols = []
|
|
247
|
+
for field in table.schema().fields:
|
|
248
|
+
if field.generated_as is not None:
|
|
249
|
+
generated_cols.append(field.column_name)
|
|
250
|
+
pd_df = pd_df.drop(columns=generated_cols)
|
|
251
|
+
|
|
252
|
+
# Drop valid-from/to columns
|
|
253
|
+
if not include_validity_period_columns:
|
|
254
|
+
pd_df = pd_df.drop(columns=["valid_from_time_utc", "valid_to_time_utc"])
|
|
205
255
|
|
|
206
256
|
return pd_df
|
|
@@ -62,7 +62,7 @@ def get_db_client() -> WarpzoneDatabaseClient:
|
|
|
62
62
|
|
|
63
63
|
|
|
64
64
|
def get_delta_db_client() -> WarpzoneDeltaDatabaseClient:
|
|
65
|
-
db_client = WarpzoneDeltaDatabaseClient.
|
|
65
|
+
db_client = WarpzoneDeltaDatabaseClient.from_resource_name(
|
|
66
66
|
os.environ["OPERATIONAL_DATA_STORAGE_ACCOUNT"],
|
|
67
67
|
credential=_credential,
|
|
68
68
|
)
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import asyncio
|
|
2
|
-
import logging
|
|
3
2
|
from contextlib import contextmanager
|
|
4
3
|
from typing import Callable
|
|
5
4
|
|
|
@@ -18,16 +17,7 @@ def configure_monitoring():
|
|
|
18
17
|
"""
|
|
19
18
|
Configure logging and tracing on Azure Function to
|
|
20
19
|
- export telemetry to App Insights
|
|
21
|
-
- suppress spamming logs
|
|
22
20
|
"""
|
|
23
|
-
# disable logging for HTTP calls to avoid log spamming
|
|
24
|
-
logging.getLogger("azure.core.pipeline.policies.http_logging_policy").setLevel(
|
|
25
|
-
logging.WARNING
|
|
26
|
-
)
|
|
27
|
-
|
|
28
|
-
# disable logging for Service Bus underlying uAMQP library to avoid log spamming
|
|
29
|
-
logging.getLogger("uamqp").setLevel(logging.WARNING)
|
|
30
|
-
|
|
31
21
|
# configure tracer provider
|
|
32
22
|
traces.configure_tracing()
|
|
33
23
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# NOTE: OpenTelemetry logging to Azure is still in EXPERIMENTAL mode!
|
|
2
2
|
import logging
|
|
3
3
|
import os
|
|
4
|
+
import threading
|
|
4
5
|
from logging import StreamHandler
|
|
5
6
|
|
|
6
7
|
from azure.monitor.opentelemetry.exporter import AzureMonitorLogExporter
|
|
@@ -27,42 +28,45 @@ _NOISY_LOGGERS = [
|
|
|
27
28
|
for _logger_name in _NOISY_LOGGERS:
|
|
28
29
|
logging.getLogger(_logger_name).setLevel(logging.WARNING)
|
|
29
30
|
|
|
31
|
+
_LOGGING_LOCK = threading.Lock()
|
|
30
32
|
LOGGING_IS_CONFIGURED = False
|
|
31
33
|
|
|
32
34
|
|
|
33
35
|
def configure_logging():
|
|
34
36
|
global LOGGING_IS_CONFIGURED
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
37
|
+
# Add thread locking to avoid race conditions during setup
|
|
38
|
+
with _LOGGING_LOCK:
|
|
39
|
+
if LOGGING_IS_CONFIGURED:
|
|
40
|
+
# logging should only be set up once
|
|
41
|
+
# to avoid duplicated log handling.
|
|
42
|
+
# Global variables is the pattern used
|
|
43
|
+
# by opentelemetry, so we use the same
|
|
44
|
+
return
|
|
41
45
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
46
|
+
# set up logger provider based on the Azure Function resource
|
|
47
|
+
# (this is make sure App Insights can track the log source correctly)
|
|
48
|
+
# (https://learn.microsoft.com/en-us/azure/azure-monitor/app/opentelemetry-enable?tabs=net#set-the-cloud-role-name-and-the-cloud-role-instance)
|
|
49
|
+
service_name = os.getenv("WEBSITE_SITE_NAME") or "unknown-service"
|
|
50
|
+
resource = Resource.create({SERVICE_NAME: service_name})
|
|
51
|
+
logs.set_logger_provider(
|
|
52
|
+
LoggerProvider(
|
|
53
|
+
resource=resource,
|
|
54
|
+
)
|
|
49
55
|
)
|
|
50
|
-
)
|
|
51
56
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
logs.get_logger_provider().add_log_record_processor(log_record_processor)
|
|
57
|
+
# setup azure monitor log exporter to send telemetry to App Insights
|
|
58
|
+
try:
|
|
59
|
+
log_exporter = AzureMonitorLogExporter()
|
|
60
|
+
except ValueError:
|
|
61
|
+
logger.warning(
|
|
62
|
+
"Cant set up logging to App Insights,"
|
|
63
|
+
" as no connection string is set."
|
|
64
|
+
)
|
|
65
|
+
else:
|
|
66
|
+
log_record_processor = BatchLogRecordProcessor(log_exporter)
|
|
67
|
+
logs.get_logger_provider().add_log_record_processor(log_record_processor)
|
|
64
68
|
|
|
65
|
-
|
|
69
|
+
LOGGING_IS_CONFIGURED = True
|
|
66
70
|
|
|
67
71
|
|
|
68
72
|
def get_logger(name: str):
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import logging
|
|
2
2
|
import os
|
|
3
|
+
import threading
|
|
3
4
|
from contextlib import contextmanager
|
|
4
5
|
from logging import StreamHandler
|
|
5
6
|
|
|
@@ -16,6 +17,7 @@ logger.addHandler(StreamHandler())
|
|
|
16
17
|
|
|
17
18
|
tracer = trace.get_tracer(__name__)
|
|
18
19
|
|
|
20
|
+
_TRACING_LOCK = threading.Lock()
|
|
19
21
|
TRACING_IS_CONFIGURED = False
|
|
20
22
|
|
|
21
23
|
|
|
@@ -28,34 +30,43 @@ def configure_tracing():
|
|
|
28
30
|
# by opentelemetry, so we use the same
|
|
29
31
|
return
|
|
30
32
|
|
|
31
|
-
#
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
33
|
+
# Add thread locking to avoid race conditions during setup
|
|
34
|
+
with _TRACING_LOCK:
|
|
35
|
+
if TRACING_IS_CONFIGURED:
|
|
36
|
+
# tracing should only be set up once
|
|
37
|
+
# to avoid duplicated trace handling.
|
|
38
|
+
# Global variables is the pattern used
|
|
39
|
+
# by opentelemetry, so we use the same
|
|
40
|
+
return
|
|
41
|
+
|
|
42
|
+
# set up tracer provider based on the Azure Function resource
|
|
43
|
+
# (this is make sure App Insights can track the trace source correctly)
|
|
44
|
+
# (https://learn.microsoft.com/en-us/azure/azure-monitor/app/opentelemetry-enable?tabs=net#set-the-cloud-role-name-and-the-cloud-role-instance).
|
|
45
|
+
# We use the ALWAYS ON sampler since otherwise spans will not be
|
|
46
|
+
# recording upon creation
|
|
47
|
+
# (https://anecdotes.dev/opentelemetry-on-google-cloud-unraveling-the-mystery-f61f044c18be)
|
|
48
|
+
service_name = os.getenv("WEBSITE_SITE_NAME") or "unknown-service"
|
|
49
|
+
resource = Resource.create({SERVICE_NAME: service_name})
|
|
50
|
+
trace.set_tracer_provider(
|
|
51
|
+
TracerProvider(
|
|
52
|
+
sampler=ALWAYS_ON,
|
|
53
|
+
resource=resource,
|
|
54
|
+
)
|
|
42
55
|
)
|
|
43
|
-
)
|
|
44
56
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
TRACING_IS_CONFIGURED = True
|
|
57
|
+
# setup azure monitor trace exporter to send telemetry to App Insights
|
|
58
|
+
try:
|
|
59
|
+
trace_exporter = AzureMonitorTraceExporter()
|
|
60
|
+
except ValueError:
|
|
61
|
+
logger.warning(
|
|
62
|
+
"Cant set up tracing to App Insights,"
|
|
63
|
+
" as no connection string is set."
|
|
64
|
+
)
|
|
65
|
+
else:
|
|
66
|
+
span_processor = BatchSpanProcessor(trace_exporter)
|
|
67
|
+
trace.get_tracer_provider().add_span_processor(span_processor)
|
|
68
|
+
|
|
69
|
+
TRACING_IS_CONFIGURED = True
|
|
59
70
|
|
|
60
71
|
|
|
61
72
|
@contextmanager
|
|
@@ -12,13 +12,10 @@ from azure.identity import DefaultAzureCredential
|
|
|
12
12
|
|
|
13
13
|
from warpzone.blobstorage.client import WarpzoneBlobClient
|
|
14
14
|
from warpzone.healthchecks import HealthCheckResult, check_health_of
|
|
15
|
-
from warpzone.monitor import traces
|
|
16
15
|
from warpzone.tablestorage.db import base_client
|
|
17
16
|
from warpzone.tablestorage.db.table_config import DataType, TableMetadata
|
|
18
17
|
from warpzone.tablestorage.tables.client import WarpzoneTableClient
|
|
19
18
|
|
|
20
|
-
tracer = traces.get_tracer(__name__)
|
|
21
|
-
|
|
22
19
|
|
|
23
20
|
class WarpzoneDatabaseClient:
|
|
24
21
|
"""Class to interact with Azure Table Storage for database queries
|
|
@@ -160,31 +157,22 @@ class WarpzoneDatabaseClient:
|
|
|
160
157
|
filters: Optional[dict[str, object]] = None,
|
|
161
158
|
use_cache: Optional[bool] = True,
|
|
162
159
|
) -> pd.DataFrame:
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
case DataType.TIME_SERIES:
|
|
176
|
-
df = self._query_time_series(
|
|
177
|
-
table_metadata, time_interval, filters, use_cache
|
|
160
|
+
table_metadata = self.get_table_metadata(table_name)
|
|
161
|
+
|
|
162
|
+
match table_metadata.data_type:
|
|
163
|
+
case DataType.TIME_SERIES:
|
|
164
|
+
df = self._query_time_series(
|
|
165
|
+
table_metadata, time_interval, filters, use_cache
|
|
166
|
+
)
|
|
167
|
+
case _:
|
|
168
|
+
if time_interval:
|
|
169
|
+
raise ValueError(
|
|
170
|
+
f"Table {table_name} is not a time series table,"
|
|
171
|
+
" and cannot be queried with a time interval."
|
|
178
172
|
)
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
f"Table {table_name} is not a time series table,"
|
|
183
|
-
" and cannot be queried with a time interval."
|
|
184
|
-
)
|
|
185
|
-
df = self._query_generic(table_metadata, None, filters, use_cache)
|
|
186
|
-
|
|
187
|
-
return df
|
|
173
|
+
df = self._query_generic(table_metadata, None, filters, use_cache)
|
|
174
|
+
|
|
175
|
+
return df
|
|
188
176
|
|
|
189
177
|
def list_tables(self):
|
|
190
178
|
return self._table_client.list_tables()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{warpzone_sdk-15.0.0.dev13 → warpzone_sdk-15.0.1.dev1}/warpzone/deltastorage/generated_columns.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{warpzone_sdk-15.0.0.dev13 → warpzone_sdk-15.0.1.dev1}/warpzone/function/processors/__init__.py
RENAMED
|
File without changes
|
{warpzone_sdk-15.0.0.dev13 → warpzone_sdk-15.0.1.dev1}/warpzone/function/processors/dependencies.py
RENAMED
|
File without changes
|
{warpzone_sdk-15.0.0.dev13 → warpzone_sdk-15.0.1.dev1}/warpzone/function/processors/outputs.py
RENAMED
|
File without changes
|
{warpzone_sdk-15.0.0.dev13 → warpzone_sdk-15.0.1.dev1}/warpzone/function/processors/triggers.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{warpzone_sdk-15.0.0.dev13 → warpzone_sdk-15.0.1.dev1}/warpzone/servicebus/events/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
{warpzone_sdk-15.0.0.dev13 → warpzone_sdk-15.0.1.dev1}/warpzone/servicebus/events/triggers.py
RENAMED
|
File without changes
|
|
File without changes
|
{warpzone_sdk-15.0.0.dev13 → warpzone_sdk-15.0.1.dev1}/warpzone/tablestorage/db/base_client.py
RENAMED
|
File without changes
|
{warpzone_sdk-15.0.0.dev13 → warpzone_sdk-15.0.1.dev1}/warpzone/tablestorage/db/table_config.py
RENAMED
|
File without changes
|
{warpzone_sdk-15.0.0.dev13 → warpzone_sdk-15.0.1.dev1}/warpzone/tablestorage/tables/__init__.py
RENAMED
|
File without changes
|
{warpzone_sdk-15.0.0.dev13 → warpzone_sdk-15.0.1.dev1}/warpzone/tablestorage/tables/client.py
RENAMED
|
File without changes
|
{warpzone_sdk-15.0.0.dev13 → warpzone_sdk-15.0.1.dev1}/warpzone/tablestorage/tables/entities.py
RENAMED
|
File without changes
|
{warpzone_sdk-15.0.0.dev13 → warpzone_sdk-15.0.1.dev1}/warpzone/tablestorage/tables/helpers.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|