Add pymssql instrumentation - #893
Open
pvital wants to merge 3 commits into
Open
Conversation
- Add src/instana/instrumentation/pymssql.py: patches pymssql.connect (and Connect alias) via the shared ConnectionFactory with module_name="mssql" - Extend CursorWrapper._collect_kvs in pep0249.py: host now falls back from 'host' to 'server' kwarg (pymssql uses server=); port defaults to 1433 when not supplied - Add "mssql" to EXIT_SPANS tuple in span/kind.py (alphabetical order) - Add _collect_mssql_attributes method to RegisteredSpan and wire it into _populate_exit_span_data after the mysql branch - Register pymssql module in boot_agent() import block Signed-off-by: Paulo Vital <paulo.vital@ibm.com>
- Add tests/clients/test_pymssql.py: TestPyMSSQL class with autouse
fixture that skips gracefully when SQL Server is unreachable;
covers all three user stories:
- US1: vanilla query, basic query, root exit span, parametrized
DML statement attributes, cursor context manager
- US2: parametrized error capture (syntax error, missing table),
no-error-on-success assertion
- US3: executemany parametrized across 2-row and 5-row batches
- SQLAlchemy bypass (no double-span)
- Add mssql_* keys to tests/helpers.py (MSSQL_HOST/PORT/DATABASE/
USER/SA_PASSWORD env vars, defaults to 127.0.0.1:1433)
- Add pymssql>=2.2.0 to tests/requirements.txt
Signed-off-by: Paulo Vital <paulo.vital@ibm.com>
Signed-off-by: Paulo Vital <paulo.vital@ibm.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds
pymssqlinstrumentation for Microsoft SQL Server, along with tests and CI updates to test it.src/instana/instrumentation/pymssql.py: patchespymssql.connect(and theConnectalias) via the sharedConnectionFactorywithmodule_name="mssql"CursorWrapper._collect_kvsinpep0249.py: host now falls back from 'host' to 'server' kwarg (pymssqluses server=)EXIT_SPANStuple inspan/kind.py(alphabetical order)_collect_mssql_attributesmethod toRegisteredSpanand wire it into_populate_exit_span_dataafter themysqlbranchpymssqlmodule in boot_agent() import blocktests/clients/test_pymssql.py:TestPyMSSQLclass with autouse fixture that skips gracefully when SQL Server is unreachable; covers all three user stories:mssql_*keys totests/helpers.py(MSSQL_HOST/PORT/DATABASE/USER/SA_PASSWORD env vars, defaults to 127.0.0.1:1433)pymssql>=2.2.0to tests/requirements.txtmcr.microsoft.com/azure-sql-edgecontainer image intodocker-compose.ymlfor local testing.mcr.microsoft.com/mssql/server:2022-latestcontainer image into the CircleCI configuration for testing across all Python versions.