dt-extensions-sdk 1.2.13__py3-none-any.whl → 1.3.0__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.
@@ -1,12 +1,11 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: dt-extensions-sdk
3
- Version: 1.2.13
3
+ Version: 1.3.0
4
4
  Project-URL: Documentation, https://github.com/dynatrace-extensions/dt-extensions-python-sdk#readme
5
5
  Project-URL: Issues, https://github.com/dynatrace-extensions/dt-extensions-python-sdk/issues
6
6
  Project-URL: Source, https://github.com/dynatrace-extensions/dt-extensions-python-sdk
7
7
  Author-email: dlopes7 <davidribeirolopes@gmail.com>
8
- License-Expression: MIT
9
- License-File: LICENSE.txt
8
+ License: MIT
10
9
  Classifier: Development Status :: 4 - Beta
11
10
  Classifier: Programming Language :: Python
12
11
  Classifier: Programming Language :: Python :: 3.10
@@ -1,13 +1,14 @@
1
- dynatrace_extension/__about__.py,sha256=bCpEm1YjYWPV0AQD731avO3Y3pKtXW57qfobWsPyITw,111
1
+ dynatrace_extension/__about__.py,sha256=UOSMeuvYrIEfkKMe5OPGxqTQkGJsMCvBMaw2t3yMuJ4,110
2
2
  dynatrace_extension/__init__.py,sha256=BvQuknmA7ti3WJi3zEXZfY7aAxJrie37VNitWICsUvI,752
3
3
  dynatrace_extension/cli/__init__.py,sha256=HCboY_eJPoqjFmoPDsBL8Jk6aNvank8K7JpkVrgwzUM,123
4
- dynatrace_extension/cli/main.py,sha256=qv6BRgoyvhThhRh64OzL6OYHSLoxiJgWlZIxUDxKX4E,17995
4
+ dynatrace_extension/cli/main.py,sha256=Z8gFcp0vIMBkzV6jUd5mwvP1U0JcLqAHoMLJw_6puz4,18260
5
5
  dynatrace_extension/cli/schema.py,sha256=d8wKUodRiaU3hfSZDWVNpD15lBfhmif2oQ-k07IxcaA,3230
6
6
  dynatrace_extension/cli/create/__init__.py,sha256=NfyOJCVlxs8dYtfDAMHS1Q5SJTuZcFzOg5rtaI-ZPRE,72
7
7
  dynatrace_extension/cli/create/create.py,sha256=apXden2M93MDDDm7aa-Os-AEtUtyKbk_PsS56j32NK4,2708
8
- dynatrace_extension/cli/create/extension_template/.gitignore.template,sha256=XixnHdyeMB2vwkGtGnwHqoWpH-9WChdyG0GXe57duhc,3078
8
+ dynatrace_extension/cli/create/extension_template/.gitignore.template,sha256=FPye23W8dqmked4HQBCDCAKFf1UbBGkwhKjQpgmXhdg,3101
9
9
  dynatrace_extension/cli/create/extension_template/README.md.template,sha256=QcV0fYqJ1PHaouKdGQgzveJY5zAFBSICp7xSfgnoQj0,637
10
- dynatrace_extension/cli/create/extension_template/activation.json.template,sha256=EtjCI3EZY5nHu4ONcWLzaOR-Et5SdU0BMkCp0ZSPSrA,257
10
+ dynatrace_extension/cli/create/extension_template/activation.json.template,sha256=qX-Fgq_JhUWNYMe1-RMcjwQPzF4scJYGfGlBr043UiY,266
11
+ dynatrace_extension/cli/create/extension_template/secrets.json.template,sha256=fr-ya8lR0TiUmr6lf-PFko6RZw6sr54FxtMbqIWBVkA,36
11
12
  dynatrace_extension/cli/create/extension_template/setup.py.template,sha256=M4HPg3UFkvmWFHAz6vHbDG5Ocb-ZiR0TQuLt9eedW1M,846
12
13
  dynatrace_extension/cli/create/extension_template/extension/activationSchema.json.template,sha256=me3DL_Q449q4VaOStTqaBL-gUkKnlafC8L2093O0LOY,2905
13
14
  dynatrace_extension/cli/create/extension_template/extension/extension.yaml.template,sha256=qDyAURGXKsZBIPjW2s1BPhD-xOC8_FoBgA33HbsOkAU,299
@@ -16,9 +17,9 @@ dynatrace_extension/cli/create/extension_template/extension_name/__main__.py.tem
16
17
  dynatrace_extension/sdk/__init__.py,sha256=RsqQ1heGyCmSK3fhuEKAcxQIRCg4gEK0-eSkIehL5Nc,86
17
18
  dynatrace_extension/sdk/activation.py,sha256=goTbT1tD2kn8xfyXFdTy_cTZNcFPJpgbvQM8HOzKECA,1480
18
19
  dynatrace_extension/sdk/callback.py,sha256=PNRvOVzNpKvpsa0wCf7HRDkfo3wMsF2otVWI9a1AAkU,6307
19
- dynatrace_extension/sdk/communication.py,sha256=lPUKxAq3mO8cO1ye79p9nuxYL-_cG6G4cJRzBZxD64w,17792
20
+ dynatrace_extension/sdk/communication.py,sha256=GVxIdLvhJW7mr1HHoS3qILGx7MNZm1ujocBrNYbfnUc,18494
20
21
  dynatrace_extension/sdk/event.py,sha256=J261imbFKpxfuAQ6Nfu3RRcsIQKKivy6fme1nww2g-8,388
21
- dynatrace_extension/sdk/extension.py,sha256=rmYF9vzA75JKvLPCr_r48EPhNz_AzWMuvlX2gmlxsIY,42808
22
+ dynatrace_extension/sdk/extension.py,sha256=gwESrAhlTtlJO-VfRFtfevmzDbd81Dj9r00u-kqs0iQ,42940
22
23
  dynatrace_extension/sdk/helper.py,sha256=ZNrO9ao2hE3KQ934vAYD74k0fCr6QTG-_bAvbk9-hi8,6562
23
24
  dynatrace_extension/sdk/metric.py,sha256=7VClzJCFJNDCxA-d69uTu1pdPtDZBTwq7fbafs_L6nQ,3690
24
25
  dynatrace_extension/sdk/runtime.py,sha256=jyYsM1x-gMnW68eWq8IoZZZBarHgIcr_nVeGDDgpRDk,2802
@@ -27,8 +28,8 @@ dynatrace_extension/sdk/vendor/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5
27
28
  dynatrace_extension/sdk/vendor/mureq/LICENSE,sha256=8AVcgZgiT_mvK1fOofXtRRr2f1dRXS_K21NuxQgP4VM,671
28
29
  dynatrace_extension/sdk/vendor/mureq/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
29
30
  dynatrace_extension/sdk/vendor/mureq/mureq.py,sha256=znF4mvzk5L03CLNozRz8UpK-fMijmSkObDFwlbhwLUg,14656
30
- dt_extensions_sdk-1.2.13.dist-info/METADATA,sha256=rp2tcD0jb7wAguIj20f1hUh_wx2SzSIgb6_Vy6skViQ,2686
31
- dt_extensions_sdk-1.2.13.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
32
- dt_extensions_sdk-1.2.13.dist-info/entry_points.txt,sha256=pweyOCgENGHjOlT6_kXYaBPOrE3p18K0UettqnNlnoE,55
33
- dt_extensions_sdk-1.2.13.dist-info/licenses/LICENSE.txt,sha256=3Zihv0lOVYHNfDkJC-tUAU6euP9r2NexsDW4w-zqgVk,1078
34
- dt_extensions_sdk-1.2.13.dist-info/RECORD,,
31
+ dt_extensions_sdk-1.3.0.dist-info/METADATA,sha256=qyJXkr0QueRXicxxBHw_wO4X9gNQsHGZf0DelNJUabM,2648
32
+ dt_extensions_sdk-1.3.0.dist-info/WHEEL,sha256=C2FUgwZgiLbznR-k0b_5k3Ai_1aASOXDss3lzCUsUug,87
33
+ dt_extensions_sdk-1.3.0.dist-info/entry_points.txt,sha256=pweyOCgENGHjOlT6_kXYaBPOrE3p18K0UettqnNlnoE,55
34
+ dt_extensions_sdk-1.3.0.dist-info/licenses/LICENSE.txt,sha256=3Zihv0lOVYHNfDkJC-tUAU6euP9r2NexsDW4w-zqgVk,1078
35
+ dt_extensions_sdk-1.3.0.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: hatchling 1.25.0
2
+ Generator: hatchling 1.26.3
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
@@ -3,4 +3,4 @@
3
3
  # SPDX-License-Identifier: MIT
4
4
 
5
5
 
6
- __version__ = "1.2.13"
6
+ __version__ = "1.3.0"
@@ -158,3 +158,6 @@ cython_debug/
158
158
  # and can be added to the global gitignore or merged into this file. For a more nuclear
159
159
  # option (not recommended) you can uncomment the following to ignore the entire idea folder.
160
160
  #.idea/
161
+
162
+ # Secrets
163
+ secrets.json
@@ -8,7 +8,7 @@
8
8
  {
9
9
  "url": "http://127.0.0.1:15672",
10
10
  "user": "guest",
11
- "password": "guest"
11
+ "password": "{{myPassword}}"
12
12
  }
13
13
  ]
14
14
  }
@@ -0,0 +1,3 @@
1
+ {
2
+ "myPassword": "secretPassword"
3
+ }
@@ -40,6 +40,7 @@ def version():
40
40
  def run(
41
41
  extension_dir: Path = typer.Argument("."),
42
42
  activation_config: str = "activation.json",
43
+ secrets: str = "secrets.json",
43
44
  fast_check: bool = typer.Option(False, "--fastcheck"),
44
45
  local_ingest: bool = typer.Option(False, "--local-ingest"),
45
46
  local_ingest_port: int = typer.Option(14499, "--local-ingest-port"),
@@ -50,6 +51,7 @@ def run(
50
51
 
51
52
  :param extension_dir: The directory of the extension, by default this is the current directory
52
53
  :param activation_config: The activation config file, by default this is activation.json
54
+ :param secrets: The secrets file to be used to enrich the activation config, by default this is secrets.json
53
55
  :param fast_check: If true, run a fastcheck and exits
54
56
  :param local_ingest: If true, send metrics to localhost:14499 on top of printing them
55
57
  :param local_ingest_port: The port to send metrics to, by default this is 14499
@@ -59,7 +61,15 @@ def run(
59
61
  # This parses the yaml, which validates it before running
60
62
  extension_yaml = ExtensionYaml(extension_dir / "extension/extension.yaml")
61
63
  try:
62
- command = [sys.executable, "-m", extension_yaml.python.runtime.module, "--activationconfig", activation_config]
64
+ command = [
65
+ sys.executable,
66
+ "-m",
67
+ extension_yaml.python.runtime.module,
68
+ "--activationconfig",
69
+ activation_config,
70
+ "--secrets",
71
+ secrets,
72
+ ]
63
73
  if fast_check:
64
74
  command.append("--fastcheck")
65
75
  if local_ingest:
@@ -324,14 +324,24 @@ class DebugClient(CommunicationClient):
324
324
  activation_config_path: str,
325
325
  extension_config_path: str,
326
326
  logger: logging.Logger,
327
+ secrets_path: str = "secrets.json",
327
328
  local_ingest: bool = False,
328
329
  local_ingest_port: int = 14499,
329
330
  print_metrics: bool = True,
330
331
  ):
332
+
333
+ self.secrets = {}
334
+ if secrets_path and Path(secrets_path).exists():
335
+ with open(secrets_path) as f:
336
+ self.secrets = json.load(f)
337
+
331
338
  self.activation_config = {}
332
339
  if activation_config_path and Path(activation_config_path).exists():
333
340
  with open(activation_config_path) as f:
334
- self.activation_config = json.load(f)
341
+ raw_activation_config = f.read()
342
+ self.activation_config = json.loads(
343
+ self.replace_secrets_in_activation_config(self.secrets, raw_activation_config)
344
+ )
335
345
 
336
346
  self.extension_config = ""
337
347
  if not extension_config_path:
@@ -430,6 +440,12 @@ class DebugClient(CommunicationClient):
430
440
  def get_cluster_time_diff(self) -> int:
431
441
  return 0
432
442
 
443
+ def replace_secrets_in_activation_config(self, secrets: dict, activation_config_string: str) -> str:
444
+ for secret_name, secret_value in secrets.items():
445
+ activation_config_string = activation_config_string.replace(f"{{{{{secret_name}}}}}", str(secret_value))
446
+
447
+ return activation_config_string
448
+
433
449
 
434
450
  def divide_into_batches(
435
451
  items: Sequence[dict | str], max_size_bytes: int, join_with: str | None = None
@@ -715,6 +715,7 @@ class Extension:
715
715
  # Debug parameters, these are used when running the extension locally
716
716
  parser.add_argument("--extensionconfig", required=False, default=None)
717
717
  parser.add_argument("--activationconfig", required=False, default="activation.json")
718
+ parser.add_argument("--secrets", required=False, default="secrets.json")
718
719
  parser.add_argument("--no-print-metrics", required=False, action="store_true")
719
720
 
720
721
  args, unknown = parser.parse_known_args()
@@ -727,6 +728,7 @@ class Extension:
727
728
  activation_config_path=args.activationconfig,
728
729
  extension_config_path=args.extensionconfig,
729
730
  logger=api_logger,
731
+ secrets_path=args.secrets,
730
732
  local_ingest=args.local_ingest,
731
733
  local_ingest_port=args.local_ingest_port,
732
734
  print_metrics=print_metrics,
@@ -748,6 +750,7 @@ class Extension:
748
750
 
749
751
  if not self._is_fastcheck:
750
752
  try:
753
+ self._heartbeat_iteration()
751
754
  self.initialize()
752
755
  if not self.is_helper:
753
756
  self.schedule(self.query, timedelta(minutes=1))
@@ -813,7 +816,6 @@ class Extension:
813
816
  # These were scheduled before the extension started, schedule them now
814
817
  for callback in self._scheduled_callbacks_before_run:
815
818
  self._schedule_callback(callback)
816
- self._heartbeat_iteration()
817
819
  self._metrics_iteration()
818
820
  self._sfm_metrics_iteration()
819
821
  self._timediff_iteration()