-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] Pure python for reference; Don't merge #556
base: main
Are you sure you want to change the base?
Conversation
…ect otlp) (#549) * Set a baseline for pure python implementation * Update solarwinds_apm/api/__init__.py Co-authored-by: Tammy Baylis <[email protected]> * Update solarwinds_apm/configurator.py Co-authored-by: Tammy Baylis <[email protected]> * Update solarwinds_apm/exporter.py Co-authored-by: Tammy Baylis <[email protected]> --------- Co-authored-by: Tammy Baylis <[email protected]>
* NH-104997 - Python: apm-config to Sampler Configuration mapping
… context not baggage
…sor-redesign branch (#559) * Added Transaction Name calculation logic --------- Co-authored-by: tammy-baylis-swi <[email protected]> Co-authored-by: Tammy Baylis <[email protected]>
…tsettings NH-106059 Suppress tracing when HTTP getsettings
* Housekept spantype logic
NH-72398 Overhaul of default and SDK-set transaction naming for Pure Python and OTLP by default
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CodeQL found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.
NH-72398 Nit: Don't need to resolve `http.route` as txn name
NH-105013 Use more upstream NoOpXProvider
NH-104796 Fix init of pure Python Oboe counters
NH-104794 Simplify ResponseTime metrics, request counters for pure Python
NH-104796 Rename as ResponseTimeProcessor
NH-104999 Remove unused `oboe_api` from configurator, sampler init
NH-104999 Remove Inbound metrics span processor, merge base into ResponseTimeProcessor
…thon / OTLP-default (#569) * Removed calculate_otlp_transaction_name and considered SW_APM_TRANSACTION_NAME in serviceentry_processor * Update solarwinds_apm/trace/serviceentry_processor.py Co-authored-by: Tammy Baylis <[email protected]> * nits --------- Co-authored-by: Tammy Baylis <[email protected]>
NH-104999 Remove now-unused ApmConfig helpers, constants
NH-104999 Remove unused configuration keys
NH-102995 No-op SolarWindsSpanExporter
# def link_oboe_lib(src_lib): | ||
# """Set up the C-extension library. | ||
# | ||
# Creates a .so library symlink ('liboboe.so') needed when the | ||
# solarwinds_apm package is built from source. This step is needed since Oboe library is platform specific. | ||
# | ||
# The src_lib parameter is the name of the library file under solarwinds_apm/extension the above mentioned symlink will | ||
# point to. If a file with the provided name does not exist, no symlinks will be created.""" | ||
# | ||
# logger.info("Create link to platform specific liboboe library file") | ||
# link_dst = 'liboboe.so' | ||
# cwd = os.getcwd() | ||
# try: | ||
# os.chdir('./solarwinds_apm/extension/') | ||
# if not os.path.exists(src_lib): | ||
# raise Exception("C-extension library file {} does not exist.".format(src_lib)) | ||
# if os.path.exists(link_dst): | ||
# # if the destination library file exists already, it needs to be deleted, otherwise linking will fail | ||
# os.remove(link_dst) | ||
# logger.info("Removed %s" % link_dst) | ||
# os.symlink(src_lib, link_dst) | ||
# logger.info("Created new link at {} to {}".format(link_dst, src_lib)) | ||
# except Exception as ecp: | ||
# logger.info("[SETUP] failed to set up link to C-extension library: {e}".format(e=ecp)) | ||
# finally: | ||
# os.chdir(cwd) | ||
|
||
# class CustomBuild(build_py): | ||
# def run(self): | ||
# self.run_command('build_ext') | ||
# build_py.run(self) | ||
# | ||
# class CustomBuildExt(build_ext): | ||
# def run(self): | ||
# # if sys.platform == 'darwin': | ||
# # return |
Check notice
Code scanning / CodeQL
Commented-out code Note
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 1 day ago
The best way to fix the problem is to remove the commented-out code. This will improve code readability and maintainability. If the commented-out code is needed for future reference, it should be documented separately or added to version control comments.
- Remove the commented-out function
link_oboe_lib
. - Remove the commented-out classes
CustomBuild
andCustomBuildExt
. - Remove the commented-out
ext_modules
definition and the relatedcmdclass
argument in thesetup
function.
-
Copy modified lines R65-R67
@@ -64,49 +64,5 @@ | ||
|
||
# def link_oboe_lib(src_lib): | ||
# """Set up the C-extension library. | ||
# | ||
# Creates a .so library symlink ('liboboe.so') needed when the | ||
# solarwinds_apm package is built from source. This step is needed since Oboe library is platform specific. | ||
# | ||
# The src_lib parameter is the name of the library file under solarwinds_apm/extension the above mentioned symlink will | ||
# point to. If a file with the provided name does not exist, no symlinks will be created.""" | ||
# | ||
# logger.info("Create link to platform specific liboboe library file") | ||
# link_dst = 'liboboe.so' | ||
# cwd = os.getcwd() | ||
# try: | ||
# os.chdir('./solarwinds_apm/extension/') | ||
# if not os.path.exists(src_lib): | ||
# raise Exception("C-extension library file {} does not exist.".format(src_lib)) | ||
# if os.path.exists(link_dst): | ||
# # if the destination library file exists already, it needs to be deleted, otherwise linking will fail | ||
# os.remove(link_dst) | ||
# logger.info("Removed %s" % link_dst) | ||
# os.symlink(src_lib, link_dst) | ||
# logger.info("Created new link at {} to {}".format(link_dst, src_lib)) | ||
# except Exception as ecp: | ||
# logger.info("[SETUP] failed to set up link to C-extension library: {e}".format(e=ecp)) | ||
# finally: | ||
# os.chdir(cwd) | ||
|
||
# class CustomBuild(build_py): | ||
# def run(self): | ||
# self.run_command('build_ext') | ||
# build_py.run(self) | ||
# | ||
# class CustomBuildExt(build_ext): | ||
# def run(self): | ||
# # if sys.platform == 'darwin': | ||
# # return | ||
# # | ||
# # platform_m = platform.machine() | ||
# # oboe_lib = f"liboboe-1.0-" | ||
# # if os.environ.get("AWS_LAMBDA_FUNCTION_NAME") and os.environ.get("LAMBDA_TASK_ROOT"): | ||
# # oboe_lib = f"{oboe_lib}lambda-" | ||
# # if is_alpine_distro(): | ||
# # oboe_lib = f"{oboe_lib}alpine-" | ||
# # oboe_lib = f"{oboe_lib}{platform_m}.so" | ||
# # | ||
# # link_oboe_lib(oboe_lib) | ||
# build_ext.run(self) | ||
|
||
|
||
|
||
|
||
@@ -118,24 +74,2 @@ | ||
|
||
# ext_modules = [ | ||
# Extension( | ||
# name='solarwinds_apm.extension._oboe', | ||
# sources=[ | ||
# 'solarwinds_apm/extension/oboe_wrap.cxx', | ||
# 'solarwinds_apm/extension/oboe_api.cpp' | ||
# ], | ||
# depends=[ | ||
# 'solarwinds_apm/extension/oboe_api.h', | ||
# ], | ||
# include_dirs=[ | ||
# 'solarwinds_apm/certs', | ||
# 'solarwinds_apm/extension/bson', | ||
# 'solarwinds_apm' | ||
# ], | ||
# libraries=['oboe', 'rt'], | ||
# library_dirs=['solarwinds_apm/extension'], | ||
# extra_compile_args=["-std=c++14"], | ||
# runtime_library_dirs=['$ORIGIN'] | ||
# ), | ||
# ] | ||
|
||
# Extra args in case old setuptools version | ||
@@ -143,7 +77,2 @@ | ||
name="solarwinds_apm", | ||
# cmdclass={ | ||
# 'build_ext': CustomBuildExt, | ||
# 'build_py': CustomBuild, | ||
# }, | ||
# ext_modules=ext_modules, | ||
python_requires='>=3.8', |
# class OboeReadyCode: | ||
# OBOE_SERVER_RESPONSE_UNKNOWN = (0, "Oboe server : unknown error") | ||
# OBOE_SERVER_RESPONSE_OK = (1, "Oboe server : is ready") |
Check notice
Code scanning / CodeQL
Commented-out code Note
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 1 day ago
The best way to fix the problem is to remove the commented-out code entirely if it is no longer needed. If the code is still relevant and should be part of the codebase, it should be reinstated. In this case, we will remove the commented-out code to clean up the codebase and avoid confusion.
-
Copy modified lines R8-R50
@@ -7,44 +7,44 @@ | ||
|
||
# class OboeReadyCode: | ||
# OBOE_SERVER_RESPONSE_UNKNOWN = (0, "Oboe server : unknown error") | ||
# OBOE_SERVER_RESPONSE_OK = (1, "Oboe server : is ready") | ||
# OBOE_SERVER_RESPONSE_TRY_LATER = ( | ||
# 2, | ||
# "Oboe server : not ready yet, try later", | ||
# ) | ||
# OBOE_SERVER_RESPONSE_LIMIT_EXCEEDED = (3, "Oboe server : limit exceeded") | ||
# OBOE_SERVER_RESPONSE_INVALID_API_KEY = (4, "Oboe server : invalid API key") | ||
# OBOE_SERVER_RESPONSE_CONNECT_ERROR = (5, "Oboe server : connection error") | ||
# | ||
# @classmethod | ||
# def code_values(cls): | ||
# code_pairs = [ | ||
# v for k, v in cls.__dict__.items() if not k.startswith("__") | ||
# ] | ||
# return {p[0]: p[1] for p in code_pairs if isinstance(p, tuple)} | ||
|
||
|
||
# class OboeReporterCode: | ||
# """Return values of Oboe Reporter""" | ||
# | ||
# OBOE_INIT_ALREADY_INIT = -1 | ||
# OBOE_INIT_OK = 0 | ||
# OBOE_INIT_WRONG_VERSION = 1 | ||
# OBOE_INIT_INVALID_PROTOCOL = 2 | ||
# OBOE_INIT_NULL_REPORTER = 3 | ||
# OBOE_INIT_DESC_ALLOC = 4 | ||
# OBOE_INIT_FILE_OPEN_LOG = 5 | ||
# OBOE_INIT_UDP_NO_SUPPORT = 6 | ||
# OBOE_INIT_UDP_OPEN = 7 | ||
# OBOE_INIT_SSL_CONFIG_AUTH = 8 | ||
# OBOE_INIT_SSL_LOAD_CERT = 9 | ||
# OBOE_INIT_SSL_REPORTER_CREATE = 10 | ||
# OBOE_INIT_SSL_MISSING_KEY = 11 | ||
# | ||
# @classmethod | ||
# def get_text_code(cls, num): | ||
# """Returns the textual representation of the numerical status code.""" | ||
# for init_status, init_code in cls.__dict__.items(): | ||
# if init_code == num: | ||
# return init_status | ||
# return None | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
# def code_values(cls): | ||
# code_pairs = [ |
Check notice
Code scanning / CodeQL
Commented-out code Note
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 1 day ago
The best way to fix the problem is to either remove the commented-out code entirely or reinstate it if it is still relevant and needed. In this case, we will remove the commented-out code to maintain a clean and readable codebase. This involves deleting the lines of commented-out code from the file solarwinds_apm/apm_oboe_codes.py
.
-
Copy modified lines R8-R50
@@ -7,44 +7,44 @@ | ||
|
||
# class OboeReadyCode: | ||
# OBOE_SERVER_RESPONSE_UNKNOWN = (0, "Oboe server : unknown error") | ||
# OBOE_SERVER_RESPONSE_OK = (1, "Oboe server : is ready") | ||
# OBOE_SERVER_RESPONSE_TRY_LATER = ( | ||
# 2, | ||
# "Oboe server : not ready yet, try later", | ||
# ) | ||
# OBOE_SERVER_RESPONSE_LIMIT_EXCEEDED = (3, "Oboe server : limit exceeded") | ||
# OBOE_SERVER_RESPONSE_INVALID_API_KEY = (4, "Oboe server : invalid API key") | ||
# OBOE_SERVER_RESPONSE_CONNECT_ERROR = (5, "Oboe server : connection error") | ||
# | ||
# @classmethod | ||
# def code_values(cls): | ||
# code_pairs = [ | ||
# v for k, v in cls.__dict__.items() if not k.startswith("__") | ||
# ] | ||
# return {p[0]: p[1] for p in code_pairs if isinstance(p, tuple)} | ||
|
||
|
||
# class OboeReporterCode: | ||
# """Return values of Oboe Reporter""" | ||
# | ||
# OBOE_INIT_ALREADY_INIT = -1 | ||
# OBOE_INIT_OK = 0 | ||
# OBOE_INIT_WRONG_VERSION = 1 | ||
# OBOE_INIT_INVALID_PROTOCOL = 2 | ||
# OBOE_INIT_NULL_REPORTER = 3 | ||
# OBOE_INIT_DESC_ALLOC = 4 | ||
# OBOE_INIT_FILE_OPEN_LOG = 5 | ||
# OBOE_INIT_UDP_NO_SUPPORT = 6 | ||
# OBOE_INIT_UDP_OPEN = 7 | ||
# OBOE_INIT_SSL_CONFIG_AUTH = 8 | ||
# OBOE_INIT_SSL_LOAD_CERT = 9 | ||
# OBOE_INIT_SSL_REPORTER_CREATE = 10 | ||
# OBOE_INIT_SSL_MISSING_KEY = 11 | ||
# | ||
# @classmethod | ||
# def get_text_code(cls, num): | ||
# """Returns the textual representation of the numerical status code.""" | ||
# for init_status, init_code in cls.__dict__.items(): | ||
# if init_code == num: | ||
# return init_status | ||
# return None | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
# class OboeReporterCode: | ||
# """Return values of Oboe Reporter""" | ||
# | ||
# OBOE_INIT_ALREADY_INIT = -1 | ||
# OBOE_INIT_OK = 0 | ||
# OBOE_INIT_WRONG_VERSION = 1 | ||
# OBOE_INIT_INVALID_PROTOCOL = 2 | ||
# OBOE_INIT_NULL_REPORTER = 3 | ||
# OBOE_INIT_DESC_ALLOC = 4 | ||
# OBOE_INIT_FILE_OPEN_LOG = 5 | ||
# OBOE_INIT_UDP_NO_SUPPORT = 6 | ||
# OBOE_INIT_UDP_OPEN = 7 | ||
# OBOE_INIT_SSL_CONFIG_AUTH = 8 | ||
# OBOE_INIT_SSL_LOAD_CERT = 9 | ||
# OBOE_INIT_SSL_REPORTER_CREATE = 10 | ||
# OBOE_INIT_SSL_MISSING_KEY = 11 | ||
# | ||
# @classmethod | ||
# def get_text_code(cls, num): | ||
# """Returns the textual representation of the numerical status code.""" | ||
# for init_status, init_code in cls.__dict__.items(): | ||
# if init_code == num: | ||
# return init_status | ||
# return None |
Check notice
Code scanning / CodeQL
Commented-out code Note
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 1 day ago
To fix the problem, we should remove the commented-out code entirely. This will help in maintaining a clean and readable codebase. The removal should be done carefully to ensure that no necessary comments or documentation are accidentally deleted.
- Identify the blocks of commented-out code.
- Remove the lines containing the commented-out code.
- Ensure that the remaining code is still functional and readable.
-
Copy modified lines R8-R50
@@ -7,44 +7,44 @@ | ||
|
||
# class OboeReadyCode: | ||
# OBOE_SERVER_RESPONSE_UNKNOWN = (0, "Oboe server : unknown error") | ||
# OBOE_SERVER_RESPONSE_OK = (1, "Oboe server : is ready") | ||
# OBOE_SERVER_RESPONSE_TRY_LATER = ( | ||
# 2, | ||
# "Oboe server : not ready yet, try later", | ||
# ) | ||
# OBOE_SERVER_RESPONSE_LIMIT_EXCEEDED = (3, "Oboe server : limit exceeded") | ||
# OBOE_SERVER_RESPONSE_INVALID_API_KEY = (4, "Oboe server : invalid API key") | ||
# OBOE_SERVER_RESPONSE_CONNECT_ERROR = (5, "Oboe server : connection error") | ||
# | ||
# @classmethod | ||
# def code_values(cls): | ||
# code_pairs = [ | ||
# v for k, v in cls.__dict__.items() if not k.startswith("__") | ||
# ] | ||
# return {p[0]: p[1] for p in code_pairs if isinstance(p, tuple)} | ||
|
||
|
||
# class OboeReporterCode: | ||
# """Return values of Oboe Reporter""" | ||
# | ||
# OBOE_INIT_ALREADY_INIT = -1 | ||
# OBOE_INIT_OK = 0 | ||
# OBOE_INIT_WRONG_VERSION = 1 | ||
# OBOE_INIT_INVALID_PROTOCOL = 2 | ||
# OBOE_INIT_NULL_REPORTER = 3 | ||
# OBOE_INIT_DESC_ALLOC = 4 | ||
# OBOE_INIT_FILE_OPEN_LOG = 5 | ||
# OBOE_INIT_UDP_NO_SUPPORT = 6 | ||
# OBOE_INIT_UDP_OPEN = 7 | ||
# OBOE_INIT_SSL_CONFIG_AUTH = 8 | ||
# OBOE_INIT_SSL_LOAD_CERT = 9 | ||
# OBOE_INIT_SSL_REPORTER_CREATE = 10 | ||
# OBOE_INIT_SSL_MISSING_KEY = 11 | ||
# | ||
# @classmethod | ||
# def get_text_code(cls, num): | ||
# """Returns the textual representation of the numerical status code.""" | ||
# for init_status, init_code in cls.__dict__.items(): | ||
# if init_code == num: | ||
# return init_status | ||
# return None | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
# if TYPE_CHECKING: | ||
# from solarwinds_apm.extension.oboe import Event, OboeAPI, Reporter |
Check notice
Code scanning / CodeQL
Commented-out code Note
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 1 day ago
To fix the problem, we should remove the commented-out code on lines 76-78. This will help in maintaining a clean and readable codebase. The removal of these lines will not affect the existing functionality of the code.
-
Copy modified lines R76-R77
@@ -75,4 +75,4 @@ | ||
|
||
# if TYPE_CHECKING: | ||
# from solarwinds_apm.extension.oboe import Event, OboeAPI, Reporter | ||
|
||
|
||
|
# def fixture_decision_auth_valid_sig(): | ||
# return { | ||
# "do_metrics": 1, | ||
# "do_sample": 1, | ||
# "auth": 0, | ||
# "auth_msg": "foo-bar", | ||
# "decision_type": 1, | ||
# "status_msg": "baz-qux", |
Check notice
Code scanning / CodeQL
Commented-out code Note test
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 1 day ago
To fix the problem, we should remove the commented-out code. This will make the code cleaner and easier to read, and it will prevent any confusion about whether the commented-out code is still relevant or needed.
- Identify the blocks of commented-out code.
- Remove the commented-out code while ensuring that the remaining code is still functional and clear.
- No additional methods, imports, or definitions are needed to implement these changes.
-
Copy modified line R16 -
Copy modified line R19 -
Copy modified line R26 -
Copy modified lines R33-R38 -
Copy modified lines R49-R51 -
Copy modified lines R112-R132
@@ -15,6 +15,6 @@ | ||
|
||
# import solarwinds_apm.extension.oboe | ||
|
||
from solarwinds_apm.sampler import ParentBasedSwSampler | ||
|
||
# pylint: disable=unused-import | ||
|
||
from .fixtures.parent_span_context import ( | ||
@@ -25,3 +25,3 @@ | ||
config_get, | ||
# fixture_swsampler, | ||
|
||
) | ||
@@ -32,8 +32,8 @@ | ||
|
||
# @pytest.fixture(autouse=True) | ||
# def fixture_mock_context_getdecisions(mocker, mock_liboboe_decision): | ||
# mocker.patch( | ||
# 'solarwinds_apm.extension.oboe.Context.getDecisions', | ||
# return_value=mock_liboboe_decision | ||
# ) | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
@@ -48,5 +48,5 @@ | ||
|
||
# @pytest.fixture(name="mock_liboboe_decision") | ||
# def fixture_mock_liboboe_decision(): | ||
# return 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 | ||
|
||
|
||
|
||
|
||
@@ -111,23 +111,23 @@ | ||
|
||
# @pytest.fixture(name="decision_auth_valid_sig") | ||
# def fixture_decision_auth_valid_sig(): | ||
# return { | ||
# "do_metrics": 1, | ||
# "do_sample": 1, | ||
# "auth": 0, | ||
# "auth_msg": "foo-bar", | ||
# "decision_type": 1, | ||
# "status_msg": "baz-qux", | ||
# } | ||
# | ||
# @pytest.fixture(name="decision_auth_invalid_sig") | ||
# def fixture_decision_auth_invalid_sig(): | ||
# return { | ||
# "do_metrics": 0, | ||
# "do_sample": 0, | ||
# "auth": 1, | ||
# "auth_msg": "foo-bar", | ||
# } | ||
# | ||
# @pytest.fixture(name="decision_not_auth_type_zero") | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
# def fixture_decision_not_auth_type_zero(): |
# def fixture_decision_auth_invalid_sig(): | ||
# return { | ||
# "do_metrics": 0, | ||
# "do_sample": 0, | ||
# "auth": 1, | ||
# "auth_msg": "foo-bar", |
Check notice
Code scanning / CodeQL
Commented-out code Note test
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 1 day ago
The best way to fix the problem is to remove the commented-out code entirely if it is no longer needed. If the code is still relevant and might be used in the future, it should be reinstated and properly integrated into the codebase. In this case, we will remove the commented-out code to maintain a clean and readable codebase.
-
Copy modified lines R112-R141
@@ -111,32 +111,32 @@ | ||
|
||
# @pytest.fixture(name="decision_auth_valid_sig") | ||
# def fixture_decision_auth_valid_sig(): | ||
# return { | ||
# "do_metrics": 1, | ||
# "do_sample": 1, | ||
# "auth": 0, | ||
# "auth_msg": "foo-bar", | ||
# "decision_type": 1, | ||
# "status_msg": "baz-qux", | ||
# } | ||
# | ||
# @pytest.fixture(name="decision_auth_invalid_sig") | ||
# def fixture_decision_auth_invalid_sig(): | ||
# return { | ||
# "do_metrics": 0, | ||
# "do_sample": 0, | ||
# "auth": 1, | ||
# "auth_msg": "foo-bar", | ||
# } | ||
# | ||
# @pytest.fixture(name="decision_not_auth_type_zero") | ||
# def fixture_decision_not_auth_type_zero(): | ||
# return { | ||
# "do_metrics": 1, | ||
# "do_sample": 1, | ||
# "auth": 0, | ||
# "auth_msg": "foo-bar", | ||
# "decision_type": 0, | ||
# "status_msg": "baz-qux", | ||
# } | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
# |
# def fixture_decision_not_auth_type_zero(): | ||
# return { | ||
# "do_metrics": 1, | ||
# "do_sample": 1, | ||
# "auth": 0, | ||
# "auth_msg": "foo-bar", | ||
# "decision_type": 0, | ||
# "status_msg": "baz-qux", |
Check notice
Code scanning / CodeQL
Commented-out code Note test
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 1 day ago
The best way to fix the problem is to remove the commented-out code entirely. This will make the code cleaner and easier to read, and it will eliminate any potential confusion about the relevance of the commented-out code. Specifically, we need to remove the commented-out function definitions and their associated return statements.
-
Copy modified lines R116-R152
@@ -115,39 +115,39 @@ | ||
# "do_metrics": 1, | ||
# "do_sample": 1, | ||
# "auth": 0, | ||
# "auth_msg": "foo-bar", | ||
# "decision_type": 1, | ||
# "status_msg": "baz-qux", | ||
# } | ||
# | ||
# @pytest.fixture(name="decision_auth_invalid_sig") | ||
# def fixture_decision_auth_invalid_sig(): | ||
# return { | ||
# "do_metrics": 0, | ||
# "do_sample": 0, | ||
# "auth": 1, | ||
# "auth_msg": "foo-bar", | ||
# } | ||
# | ||
# @pytest.fixture(name="decision_not_auth_type_zero") | ||
# def fixture_decision_not_auth_type_zero(): | ||
# return { | ||
# "do_metrics": 1, | ||
# "do_sample": 1, | ||
# "auth": 0, | ||
# "auth_msg": "foo-bar", | ||
# "decision_type": 0, | ||
# "status_msg": "baz-qux", | ||
# } | ||
# | ||
# @pytest.fixture(name="decision_not_auth_type_nonzero") | ||
# def fixture_decision_auth_type_nonzero(): | ||
# return { | ||
# "do_metrics": 1, | ||
# "do_sample": 1, | ||
# "auth": 0, | ||
# "auth_msg": "foo-bar", | ||
# "decision_type": -1, | ||
# "status_msg": "baz-qux", | ||
# } | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
# |
# def fixture_decision_auth_type_nonzero(): | ||
# return { | ||
# "do_metrics": 1, | ||
# "do_sample": 1, | ||
# "auth": 0, | ||
# "auth_msg": "foo-bar", | ||
# "decision_type": -1, | ||
# "status_msg": "baz-qux", |
Check notice
Code scanning / CodeQL
Commented-out code Note test
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 1 day ago
The best way to fix the problem is to remove the commented-out code entirely. This will clean up the codebase and eliminate any potential confusion for future developers. If the commented-out code is needed for future reference, it should be documented separately or added to a version control system where it can be retrieved if necessary.
- Remove the commented-out code from lines 127 to 163 in the file
tests/unit/test_sampler/test_sampler.py
. - Ensure that the remaining code is properly formatted and that no functionality is lost.
-
Copy modified lines R127-R163
@@ -126,39 +126,39 @@ | ||
# "do_metrics": 0, | ||
# "do_sample": 0, | ||
# "auth": 1, | ||
# "auth_msg": "foo-bar", | ||
# } | ||
# | ||
# @pytest.fixture(name="decision_not_auth_type_zero") | ||
# def fixture_decision_not_auth_type_zero(): | ||
# return { | ||
# "do_metrics": 1, | ||
# "do_sample": 1, | ||
# "auth": 0, | ||
# "auth_msg": "foo-bar", | ||
# "decision_type": 0, | ||
# "status_msg": "baz-qux", | ||
# } | ||
# | ||
# @pytest.fixture(name="decision_not_auth_type_nonzero") | ||
# def fixture_decision_auth_type_nonzero(): | ||
# return { | ||
# "do_metrics": 1, | ||
# "do_sample": 1, | ||
# "auth": 0, | ||
# "auth_msg": "foo-bar", | ||
# "decision_type": -1, | ||
# "status_msg": "baz-qux", | ||
# } | ||
# | ||
# @pytest.fixture(name="decision_signed_tt_traced") | ||
# def fixture_decision_signed_tt_traced(mocker): | ||
# """Case 8""" | ||
# return { | ||
# "do_sample": 1, | ||
# "decision_type": 1, | ||
# "auth": 0, | ||
# "auth_msg": "ok", | ||
# "status": 0, | ||
# "status_msg": "ok", | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
# } |
# def fixture_decision_signed_tt_traced(mocker): | ||
# """Case 8""" | ||
# return { | ||
# "do_sample": 1, | ||
# "decision_type": 1, | ||
# "auth": 0, | ||
# "auth_msg": "ok", | ||
# "status": 0, | ||
# "status_msg": "ok", | ||
# } | ||
# | ||
# @pytest.fixture(name="decision_non_tt_traced") | ||
# def fixture_decision_non_tt_traced(mocker): | ||
# """Case 14""" | ||
# return { | ||
# "do_sample": 1, | ||
# "decision_type": 0, | ||
# "auth": -1, | ||
# "auth_msg": "", | ||
# "status": 0, | ||
# "status_msg": "ok", | ||
# } | ||
# | ||
# @pytest.fixture(name="decision_unsigned_tt_not_traced") | ||
# def fixture_decision_unsigned_tt_not_traced(mocker): | ||
# """Case 11 - feature disabled""" | ||
# return { | ||
# "do_sample": 0, | ||
# "decision_type": -1, | ||
# "auth": -1, | ||
# "auth_msg": "", | ||
# "status": -3, | ||
# "status_msg": "trigger-tracing-disabled", | ||
# } |
Check notice
Code scanning / CodeQL
Commented-out code Note test
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 1 day ago
The best way to fix the problem is to remove the commented-out code entirely. This will clean up the codebase and make it easier for developers to read and maintain. If the commented-out code is needed for future reference, it should be documented separately or added to a version control system where it can be retrieved if necessary.
- Remove the commented-out code from lines 137 to 188 in the file
tests/unit/test_sampler/test_sampler.py
. - Ensure that the remaining code is properly formatted and that no functionality is lost.
-
Copy modified lines R137-R188
@@ -136,54 +136,54 @@ | ||
# "do_sample": 1, | ||
# "auth": 0, | ||
# "auth_msg": "foo-bar", | ||
# "decision_type": 0, | ||
# "status_msg": "baz-qux", | ||
# } | ||
# | ||
# @pytest.fixture(name="decision_not_auth_type_nonzero") | ||
# def fixture_decision_auth_type_nonzero(): | ||
# return { | ||
# "do_metrics": 1, | ||
# "do_sample": 1, | ||
# "auth": 0, | ||
# "auth_msg": "foo-bar", | ||
# "decision_type": -1, | ||
# "status_msg": "baz-qux", | ||
# } | ||
# | ||
# @pytest.fixture(name="decision_signed_tt_traced") | ||
# def fixture_decision_signed_tt_traced(mocker): | ||
# """Case 8""" | ||
# return { | ||
# "do_sample": 1, | ||
# "decision_type": 1, | ||
# "auth": 0, | ||
# "auth_msg": "ok", | ||
# "status": 0, | ||
# "status_msg": "ok", | ||
# } | ||
# | ||
# @pytest.fixture(name="decision_non_tt_traced") | ||
# def fixture_decision_non_tt_traced(mocker): | ||
# """Case 14""" | ||
# return { | ||
# "do_sample": 1, | ||
# "decision_type": 0, | ||
# "auth": -1, | ||
# "auth_msg": "", | ||
# "status": 0, | ||
# "status_msg": "ok", | ||
# } | ||
# | ||
# @pytest.fixture(name="decision_unsigned_tt_not_traced") | ||
# def fixture_decision_unsigned_tt_not_traced(mocker): | ||
# """Case 11 - feature disabled""" | ||
# return { | ||
# "do_sample": 0, | ||
# "decision_type": -1, | ||
# "auth": -1, | ||
# "auth_msg": "", | ||
# "status": -3, | ||
# "status_msg": "trigger-tracing-disabled", | ||
# } | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
No description provided.