omnata-plugin-runtime 0.11.5a322__py3-none-any.whl → 0.11.6a323__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.
@@ -9,9 +9,10 @@ from typing import Dict, List, Optional
9
9
  from snowflake.snowpark import Session
10
10
  from pydantic import ValidationError
11
11
  from snowflake import telemetry
12
- from opentelemetry import trace
12
+ from opentelemetry import trace, metrics
13
13
 
14
14
  tracer = trace.get_tracer('omnata_plugin_runtime')
15
+ meter = metrics.get_meter('omnata_plugin_runtime')
15
16
 
16
17
  class CustomLoggerAdapter(logging.LoggerAdapter):
17
18
  """
@@ -48,7 +48,7 @@ from snowflake.snowpark import Session
48
48
  from snowflake.snowpark.functions import col
49
49
  from tenacity import Retrying, stop_after_attempt, wait_fixed, retry_if_exception_message
50
50
 
51
- from .logging import OmnataPluginLogHandler, logger, tracer
51
+ from .logging import OmnataPluginLogHandler, logger, tracer, meter
52
52
  from opentelemetry import context
53
53
  import math
54
54
  import numpy as np
@@ -2330,6 +2330,15 @@ def __managed_inbound_processing_worker(
2330
2330
  try:
2331
2331
  stream: StoredStreamConfiguration = streams_queue.get_nowait()
2332
2332
  logger.debug(f"stream returned from queue: {stream}")
2333
+ sync_request: InboundSyncRequest = cast(
2334
+ InboundSyncRequest, plugin_class_obj._sync_request
2335
+ ) # pylint: disable=protected-access
2336
+ stream_duration_counter = meter.create_histogram(
2337
+ name="omnata.sync_run.stream_duration",
2338
+ description="The duration of stream processing",
2339
+ unit="s",
2340
+ )
2341
+ start_time = time.time()
2333
2342
  # restore the first argument, was originally the dataframe/generator but now it's the appropriately sized dataframe
2334
2343
  try:
2335
2344
  with tracer.start_as_current_span("managed_inbound_processing") as managed_inbound_processing_span:
@@ -2341,7 +2350,7 @@ def __managed_inbound_processing_worker(
2341
2350
  logger.info(f"worker {worker_index} requested that {stream.stream_name} be not marked as complete")
2342
2351
  else:
2343
2352
  logger.info(f"worker {worker_index} marking stream {stream.stream_name} as complete")
2344
- plugin_class_obj._sync_request.mark_stream_complete(stream.stream_name)
2353
+ sync_request.mark_stream_complete(stream.stream_name)
2345
2354
  except InterruptedWhileWaitingException:
2346
2355
  # If an inbound run is cancelled while waiting for rate limiting, this should mean that
2347
2356
  # the cancellation is handled elsewhere, so we don't need to do anything special here other than stop waiting
@@ -2361,6 +2370,19 @@ def __managed_inbound_processing_worker(
2361
2370
  omnata_plugin_logger.error(f"{type(e).__name__} syncing stream {stream.stream_name}",
2362
2371
  exc_info=True,
2363
2372
  extra={'stream_name':stream.stream_name})
2373
+ finally:
2374
+ duration = time.time() - start_time
2375
+ stream_duration_counter.record(
2376
+ duration,
2377
+ attributes={
2378
+ "stream_name": stream.stream_name,
2379
+ "sync_run_id": str(sync_request._run_id),
2380
+ "sync_id": str(sync_request._sync_id),
2381
+ "branch_name": str(sync_request._branch_name) if sync_request._branch_name is not None else 'main',
2382
+ "sync_direction": "inbound",
2383
+ "plugin_id": plugin_class_obj.get_manifest().plugin_id,
2384
+ },
2385
+ )
2364
2386
  except queue.Empty:
2365
2387
  logger.debug("streams queue is empty")
2366
2388
  return
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: omnata-plugin-runtime
3
- Version: 0.11.5a322
3
+ Version: 0.11.6a323
4
4
  Summary: Classes and common runtime components for building and running Omnata Plugins
5
5
  License-File: LICENSE
6
6
  Author: James Weakley
@@ -3,11 +3,11 @@ omnata_plugin_runtime/api.py,sha256=5gbjbnFy72Xjf0E3kbG23G0V2J3CorvD5kpBn_BkdlI,
3
3
  omnata_plugin_runtime/configuration.py,sha256=SffokJfgvy6V3kUsoEjXcK3GdNgHo6U3mgBEs0qBv4I,46972
4
4
  omnata_plugin_runtime/forms.py,sha256=Lrbr3otsFDrvHWJw7v-slsW4PvEHJ6BG1Yl8oaJfiDo,20529
5
5
  omnata_plugin_runtime/json_schema.py,sha256=ZfHMG-XSJBE9Smt33Y6GPpl5skF7pB1TRCf9AvWuw-Y,59705
6
- omnata_plugin_runtime/logging.py,sha256=WBuZt8lF9E5oFWM4KYQbE8dDJ_HctJ1pN3BHwU6rcd0,4461
7
- omnata_plugin_runtime/omnata_plugin.py,sha256=xqAIxFdb2X4ryK4VetQxI4u4UdMyN2xs4toLHKasIdU,142045
6
+ omnata_plugin_runtime/logging.py,sha256=qUtRA9syQNnjfJZHA2W18K282voXX6vHwrBIPOBo1n8,4521
7
+ omnata_plugin_runtime/omnata_plugin.py,sha256=GTFxri5FIkZhOI70FQpeLoKRo3zOQlqo2dUUUTaDppE,143134
8
8
  omnata_plugin_runtime/plugin_entrypoints.py,sha256=_1pDLov3iQorGmfcae8Sw2bVjxw1vYeowBaKKNzRclQ,32629
9
9
  omnata_plugin_runtime/rate_limiting.py,sha256=qpr5esU4Ks8hMzuMpSR3gLFdor2ZUXYWCjmsQH_K6lQ,25882
10
- omnata_plugin_runtime-0.11.5a322.dist-info/METADATA,sha256=u9a0Z2qe84l1vagmjgTmZYCU1oULyiPTBRsBrltHC5A,2183
11
- omnata_plugin_runtime-0.11.5a322.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
12
- omnata_plugin_runtime-0.11.5a322.dist-info/licenses/LICENSE,sha256=rGaMQG3R3F5-JGDp_-rlMKpDIkg5n0SI4kctTk8eZSI,56
13
- omnata_plugin_runtime-0.11.5a322.dist-info/RECORD,,
10
+ omnata_plugin_runtime-0.11.6a323.dist-info/METADATA,sha256=hrxfalJXwUkafbhXZbNkTrt0Jq6EBx1fbAnIWglAEfQ,2183
11
+ omnata_plugin_runtime-0.11.6a323.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
12
+ omnata_plugin_runtime-0.11.6a323.dist-info/licenses/LICENSE,sha256=rGaMQG3R3F5-JGDp_-rlMKpDIkg5n0SI4kctTk8eZSI,56
13
+ omnata_plugin_runtime-0.11.6a323.dist-info/RECORD,,