omnata-plugin-runtime 0.7.0a185__tar.gz → 0.8.0a186__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.7.0a185
3
+ Version: 0.8.0a186
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
@@ -19,9 +19,11 @@ Requires-Dist: idna (<=3.7)
19
19
  Requires-Dist: jinja2 (>=3.1.2,<=3.1.4)
20
20
  Requires-Dist: markupsafe (<=2.1.3)
21
21
  Requires-Dist: numpy (<1.27.0)
22
+ Requires-Dist: opentelemetry-api (<=1.23.0)
22
23
  Requires-Dist: packaging (<=24.1)
23
24
  Requires-Dist: pandas (<=2.2.2)
24
25
  Requires-Dist: platformdirs (<=3.10.0)
26
+ Requires-Dist: protobuf (<=4.25.3)
25
27
  Requires-Dist: pyarrow (<=16.1.0)
26
28
  Requires-Dist: pycparser (<=2.21)
27
29
  Requires-Dist: pydantic (>=2,<=2.8.2)
@@ -34,10 +36,12 @@ Requires-Dist: requests (>=2,<=2.32.3)
34
36
  Requires-Dist: setuptools (<=72.1.0)
35
37
  Requires-Dist: snowflake-connector-python (>=3,<=3.12.0)
36
38
  Requires-Dist: snowflake-snowpark-python (==1.23.0)
39
+ Requires-Dist: snowflake-telemetry-python (<=0.5.0)
37
40
  Requires-Dist: tenacity (>=8,<=8.2.3)
38
41
  Requires-Dist: tomlkit (<=0.11.1)
39
42
  Requires-Dist: urllib3 (<=2.2.2)
40
43
  Requires-Dist: wheel (<=0.43.0)
44
+ Requires-Dist: wrapt (<=1.14.1)
41
45
  Description-Content-Type: text/markdown
42
46
 
43
47
  # omnata-plugin-runtime
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "omnata-plugin-runtime"
3
- version = "0.7.0-a185"
3
+ version = "0.8.0-a186"
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"
@@ -38,6 +38,10 @@ wheel = "<=0.43.0" # latest version available on Snowflake Anaconda
38
38
  pyyaml = "<=6.0.1" # latest version available on Snowflake Anaconda
39
39
  cffi = "<=1.16.0" # latest version available on Snowflake Anaconda
40
40
  pyarrow = "<=16.1.0" # latest version available on Snowflake Anaconda
41
+ wrapt = "<=1.14.1" # latest version available on Snowflake Anaconda
42
+ opentelemetry-api = "<=1.23.0" # latest version available on Snowflake Anaconda
43
+ snowflake-telemetry-python = "<=0.5.0" # latest version available on Snowflake Anaconda
44
+ protobuf = "<=4.25.3" # latest version available on Snowflake Anaconda
41
45
 
42
46
  [tool.poetry.dev-dependencies]
43
47
  pytest = "^6.2.4"
@@ -4,12 +4,38 @@ Custom logging functionality for Omnata
4
4
  import logging
5
5
  import logging.handlers
6
6
  import traceback
7
- from logging import Logger
7
+ from logging import Logger, getLogger
8
8
  from typing import Dict, List, Optional
9
9
  from snowflake.snowpark import Session
10
10
  from pydantic import ValidationError
11
+ from opentelemetry import trace
11
12
 
12
13
 
14
+ class CustomLoggerAdapter(logging.LoggerAdapter):
15
+ """
16
+ A logger adapter which attaches current trace and span IDs to log messages, so that they can be correlated to traces.
17
+ Also offers the ability to add static extras.
18
+ """
19
+ def __init__(self, logger:logging.Logger, extra):
20
+ super(CustomLoggerAdapter, self).__init__(logger, extra)
21
+ self.extra_extras = {}
22
+
23
+ def add_extra(self, key, value):
24
+ self.extra_extras[key] = value
25
+
26
+ def process(self, msg, kwargs):
27
+ extra = kwargs.get("extra", {})
28
+ current_span = trace.get_current_span()
29
+ context = current_span.get_span_context() if current_span is not None else None
30
+ if context is not None:
31
+ extra["trace_id"] = format(context.trace_id, 'x') # format as hex string to be consistent with Snowflake's handler
32
+ extra["span_id"] = format(context.span_id, 'x')
33
+ extra.update(self.extra_extras)
34
+ kwargs["extra"] = extra
35
+ return msg, kwargs
36
+
37
+ logger = CustomLoggerAdapter(getLogger("omnata_plugin"), {})
38
+
13
39
  def log_exception(exception: Exception, logger_instance: Logger):
14
40
  """
15
41
  Logs an exception to a logger