omnata-plugin-runtime 0.8.0a196__tar.gz → 0.8.0a199__tar.gz

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: omnata-plugin-runtime
3
- Version: 0.8.0a196
3
+ Version: 0.8.0a199
4
4
  Summary: Classes and common runtime components for building and running Omnata Plugins
5
5
  Author: James Weakley
6
6
  Author-email: james.weakley@omnata.com
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "omnata-plugin-runtime"
3
- version = "0.8.0-a196"
3
+ version = "0.8.0-a199"
4
4
  description = "Classes and common runtime components for building and running Omnata Plugins"
5
5
  authors = ["James Weakley <james.weakley@omnata.com>"]
6
6
  readme = "README.md"
@@ -48,6 +48,7 @@ from snowflake.snowpark.functions import col
48
48
  from tenacity import Retrying, stop_after_attempt, wait_fixed, retry_if_exception_message
49
49
 
50
50
  from .logging import OmnataPluginLogHandler, logger, tracer
51
+ from opentelemetry import context
51
52
 
52
53
  from .api import (
53
54
  PluginMessage,
@@ -316,6 +317,8 @@ class SyncRequest(ABC):
316
317
  self._cancel_checking_task = None
317
318
  self._rate_limit_update_task = None
318
319
  self._last_stream_progress_update = None
320
+ # store the opentelemetry context so that it can be attached inside threads
321
+ self.opentelemetry_context = context.get_current()
319
322
 
320
323
  threading.excepthook = self.thread_exception_hook
321
324
  if self.development_mode is False:
@@ -387,6 +390,7 @@ class SyncRequest(ABC):
387
390
  """
388
391
  Designed to be run in a thread, this method polls the results every 20 seconds and sends them back to Snowflake.
389
392
  """
393
+ context.attach(self.opentelemetry_context)
390
394
  while not cancellation_token.is_set():
391
395
  logger.debug("apply results worker checking for results")
392
396
  self.apply_results_queue()
@@ -399,6 +403,7 @@ class SyncRequest(ABC):
399
403
  It also gives us the latest rate limit state from Snowflake, so that activity on other syncs/branches can
400
404
  impact rate limiting on this one.
401
405
  """
406
+ context.attach(self.opentelemetry_context)
402
407
  while not cancellation_token.is_set():
403
408
  try:
404
409
  self.apply_rate_limit_state()
@@ -408,6 +413,7 @@ class SyncRequest(ABC):
408
413
  logger.info("rate limit update worker exiting")
409
414
 
410
415
  def __cancel_checking_worker(self, cancellation_token:threading.Event):
416
+ context.attach(self.opentelemetry_context)
411
417
  """
412
418
  Designed to be run in a thread, this method checks to see if the sync run has been cancelled
413
419
  or if the deadline has been reached.
@@ -1637,6 +1643,8 @@ class OmnataPlugin(ABC):
1637
1643
  take care of various status updates and loading enqueued results.
1638
1644
  Only set this to True if you plan to do all of this yourself (e.g. in a Java stored proc)
1639
1645
  """
1646
+ # store the opentelemetry context so that it can be attached inside threads
1647
+ self.opentelemetry_context = context.get_current()
1640
1648
 
1641
1649
 
1642
1650
  @abstractmethod
@@ -1946,6 +1954,7 @@ def __managed_outbound_processing_worker(
1946
1954
  Consumes a fixed sized set of records by passing them to the wrapped function,
1947
1955
  while adhering to the defined API constraints.
1948
1956
  """
1957
+ context.attach(plugin_class_obj.opentelemetry_context)
1949
1958
  logger.debug(
1950
1959
  f"worker {worker_index} processing. Cancelled: {cancellation_token.is_set()}"
1951
1960
  )
@@ -2128,6 +2137,7 @@ def __managed_inbound_processing_worker(
2128
2137
  A worker thread for the managed_inbound_processing annotation.
2129
2138
  Passes single streams at a time to the wrapped function, adhering to concurrency constraints.
2130
2139
  """
2140
+ context.attach(plugin_class_obj.opentelemetry_context)
2131
2141
  while not cancellation_token.is_set():
2132
2142
  # Get our generator object out of the queue
2133
2143
  logger.debug(
@@ -88,7 +88,7 @@ class PluginEntrypoint:
88
88
  logger.add_extra('omnata.sync.id', request.sync_id)
89
89
  logger.add_extra('omnata.sync.direction', request.sync_direction)
90
90
  logger.add_extra('omnata.connection.id', request.connection_id)
91
- logger.add_extra('omnata.sync.run_id', request.run_id)
91
+ logger.add_extra('omnata.sync_run.id', request.run_id)
92
92
  logger.add_extra('omnata.sync_branch.id', request.sync_branch_id)
93
93
  logger.add_extra('omnata.sync_branch.name', request.sync_branch_name)
94
94
  logger.info("Entered sync method")