qontract-reconcile 0.10.2.dev259__py3-none-any.whl → 0.10.2.dev261__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,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: qontract-reconcile
3
- Version: 0.10.2.dev259
3
+ Version: 0.10.2.dev261
4
4
  Summary: Collection of tools to reconcile services with their desired state as defined in the app-interface DB.
5
5
  Project-URL: homepage, https://github.com/app-sre/qontract-reconcile
6
6
  Project-URL: repository, https://github.com/app-sre/qontract-reconcile
@@ -449,6 +449,22 @@ GQL definitions and generated classes can be found [here](reconcile/gql_definiti
449
449
 
450
450
  `faulthandler` is enabled for this project and SIGUSR1 is registered to dump the traceback. To do so, you can use `kill -USR1 pid` where pid is the ID of the qontract-reconcile process.
451
451
 
452
+ ## Profiling
453
+
454
+ Enable the Python cProfile module by setting the environment variable `ENABLE_PROFILING=1` before running the integration. This will generate a profile file `/tmp/profile.prof`.
455
+
456
+ You can then analyze the profile using `snakeviz`:
457
+
458
+ ```sh
459
+ snakeviz /tmp/profile.prof
460
+ ```
461
+
462
+ > :information_source: Note
463
+ >
464
+ > `cProfile` doesn't support multithreading, but it can still highlight performance issues on the main thread.
465
+ > If you need to profile multithreaded code, consider using [py-spy](https://github.com/benfred/py-spy) or similar tools that support sampling profiling.
466
+ > Also [memray](https://github.com/bloomberg/memray) could be beneficial for memory profiling.
467
+
452
468
  ## Code style guide
453
469
 
454
470
  Qontract-reconcile uses [PEP8](https://peps.python.org/pep-0008/) as the code style guide.
@@ -93,7 +93,7 @@ reconcile/query_validator.py,sha256=MSh5pKLBksws4AqfuvT8nrIGucIbqX-IOzYyPYTLO7k,
93
93
  reconcile/requests_sender.py,sha256=914iluuF4UVgG3VyxxtnHOu4yf6YKS2fIy6PViSsFTQ,3875
94
94
  reconcile/resource_scraper.py,sha256=znXCHrU7YwPfKuxGBiUrV7T1tYtn4vlz9qmZlfy6Flg,2307
95
95
  reconcile/resource_template_tester.py,sha256=DsKvBuNLPxm4Fa-e1YHHySnhThm5i_j-nF3G4b02Mz0,2416
96
- reconcile/run_integration.py,sha256=BMqJi7LbLs2fqmfH8ctl2hYcGulHG-n3QxEnIgGfw18,9713
96
+ reconcile/run_integration.py,sha256=brbNFEQpHLeLIEN-sDpIctyrx8aiL5Vu9YLecdwwykk,10221
97
97
  reconcile/saas_file_validator.py,sha256=tyvFYU6lnkfDYIkAIr5pWqSvO5Yc6TagZ-quJYD2dtI,2547
98
98
  reconcile/sendgrid_teammates.py,sha256=oO8QbLb4s1o8A6CGiCagN9CmS05BSS_WLztuY0Ym9D8,4773
99
99
  reconcile/service_dependencies.py,sha256=G2qCuYFc8wQLpRxkdhmibxSAl3nUM3hcan4x50W_mCA,4335
@@ -797,7 +797,7 @@ tools/saas_promotion_state/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJ
797
797
  tools/saas_promotion_state/saas_promotion_state.py,sha256=oF7C4hpIgyMTwTRm3Aun3cDCHIjVar65JoLp6NcJHlU,3909
798
798
  tools/sre_checkpoints/__init__.py,sha256=CDaDaywJnmRCLyl_NCcvxi-Zc0hTi_3OdwKiFOyS39I,145
799
799
  tools/sre_checkpoints/util.py,sha256=zEDbGr18ZeHNQwW8pUsr2JRjuXIPz--WAGJxZo9sv_Y,894
800
- qontract_reconcile-0.10.2.dev259.dist-info/METADATA,sha256=Set5kuKqo7t8Zg8eXwKelmzWOPVXIbcMV6U8d-MWVA0,23827
801
- qontract_reconcile-0.10.2.dev259.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
802
- qontract_reconcile-0.10.2.dev259.dist-info/entry_points.txt,sha256=5i9l54La3vQrDLAdwDKQWC0iG4sV9RRfOb1BpvzOWLc,698
803
- qontract_reconcile-0.10.2.dev259.dist-info/RECORD,,
800
+ qontract_reconcile-0.10.2.dev261.dist-info/METADATA,sha256=FfdtlJxjSP74I6Qi-sXO-lkipfa8ghTnPug-yPAWJ4Y,24501
801
+ qontract_reconcile-0.10.2.dev261.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
802
+ qontract_reconcile-0.10.2.dev261.dist-info/entry_points.txt,sha256=5i9l54La3vQrDLAdwDKQWC0iG4sV9RRfOb1BpvzOWLc,698
803
+ qontract_reconcile-0.10.2.dev261.dist-info/RECORD,,
@@ -1,5 +1,7 @@
1
1
  #!/usr/bin/env python3
2
2
 
3
+ import contextlib
4
+ import cProfile
3
5
  import logging
4
6
  import os
5
7
  import sys
@@ -78,6 +80,15 @@ if LOG_FILE is not None:
78
80
  logging.basicConfig(level=LOG_LEVEL, handlers=HANDLERS)
79
81
 
80
82
 
83
+ PROFILE_DUMP_FILE = os.environ.get("PROFILE_DUMP_FILE", "/tmp/profile.prof")
84
+ profiling_enabled = os.environ.get("ENABLE_PROFILING", "").lower() in {
85
+ "true",
86
+ "1",
87
+ "yes",
88
+ }
89
+ profiler = cProfile.Profile() if profiling_enabled else contextlib.nullcontext()
90
+
91
+
81
92
  class PushgatewayBadConfigError(Exception):
82
93
  pass
83
94
 
@@ -238,7 +249,11 @@ def main() -> None:
238
249
  try:
239
250
  with command.make_context(info_name=COMMAND_NAME, args=args) as ctx: # type: ignore
240
251
  ctx.ensure_object(dict)
241
- command.invoke(ctx)
252
+ with profiler as pr:
253
+ command.invoke(ctx)
254
+ if pr:
255
+ LOG.info(f"Profiling data written to {PROFILE_DUMP_FILE}")
256
+ pr.dump_stats(PROFILE_DUMP_FILE)
242
257
  return_code = 0
243
258
  # This is for when the integration explicitly
244
259
  # calls sys.exit(N)