-
Notifications
You must be signed in to change notification settings - Fork 469
Add mariadb #2570
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
Merged
Merged
Add mariadb #2570
Changes from all commits
Commits
Show all changes
73 commits
Select commit
Hold shift + click to select a range
39fad4f
adding comment to clarify that log line occurs when DATADOG_PRIORITY_…
ZStriker19 9a22d05
Update writer.py
ZStriker19 aed7bfe
got mariadb integration working on sample app
ZStriker19 2d74914
testing for mariadb integration setup
ZStriker19 a501d42
fixed riot.py file so mariadb tests run
ZStriker19 3f23a64
beginning conversion of mysql tests to mariadb tests with new formats
ZStriker19 71b3506
committing to merge in master updates
ZStriker19 cdc7aab
Merge remote-tracking branch 'origin' into add_mariadb
ZStriker19 b37d210
made all mariadb tests pass
ZStriker19 6001351
added first snapshot test
ZStriker19 3e32f6f
removed print statement and added more snapshot tests for mariadb int…
ZStriker19 bfd87e9
updated docs to include mariadb integration and made documentation in…
ZStriker19 0500961
Merge remote-tracking branch 'origin' into add_mariadb
ZStriker19 6c0d22a
added mariadb to circleci config.yaml
ZStriker19 74e945a
added mariadb build steps to dev image
ZStriker19 cb8b2ab
added malformed query snapshot test
ZStriker19 158fff0
Fix grammar in mariadb docs
ZStriker19 5330d3d
added mariadb test snapshots, reformatted tests, added guards for pat…
ZStriker19 7999026
Merge branch 'add_mariadb' of github.com:DataDog/dd-trace-py into add…
ZStriker19 015adf8
Merge branch 'master' into add_mariadb
ZStriker19 1f29742
added release notes
ZStriker19 2b8683a
add link to library this instruments
ZStriker19 8d3e56b
remove comment
ZStriker19 eac06e3
Update ddtrace/contrib/mariadb/__init__.py
ZStriker19 489eddb
Update ddtrace/contrib/mariadb/__init__.py
ZStriker19 b7cb45e
Update ddtrace/contrib/mariadb/patch.py
ZStriker19 123d41b
Update docs/integrations.rst
ZStriker19 ceb1923
Update releasenotes/notes/mariadb-8e7bc94a0d1b8f02.yaml
ZStriker19 e6c0759
edits to comments
ZStriker19 68c82d5
Update tests/contrib/mariadb/test_mariadb.py
ZStriker19 8626c45
Update tests/contrib/mariadb/test_mariadb.py
ZStriker19 faad6eb
Update tests/contrib/mariadb/test_mariadb.py
ZStriker19 8ecb782
switched tests to snapshots and other small changes
ZStriker19 20d0cb9
getting rid of .DS_Stores
ZStriker19 2676143
getting rid of DS_Store
ZStriker19 cb628d7
fixing merge conflict
ZStriker19 f2ba27e
Merge branch 'master' into add_mariadb
ZStriker19 ce44785
Update ddtrace/contrib/mariadb/__init__.py
ZStriker19 597a69d
Update tests/contrib/mariadb/test_mariadb.py
ZStriker19 6ddcde4
Update tests/contrib/mariadb/test_mariadb.py
ZStriker19 1903bc2
fix merge conflict
ZStriker19 cb8cbbe
remove benchmark changes
ZStriker19 721e00a
Update tests/utils.py
ZStriker19 f8a7f7f
Merge branch 'add_mariadb' of github.com:DataDog/dd-trace-py into add…
ZStriker19 7c37778
Update ddtrace/contrib/mariadb/__init__.py
ZStriker19 24616bb
Update .gitignore
ZStriker19 8c444d0
Update ddtrace/contrib/mariadb/patch.py
ZStriker19 0282b78
Merge branch 'add_mariadb' of github.com:DataDog/dd-trace-py into add…
ZStriker19 92eac3e
Update .gitignore
ZStriker19 f874781
Update .gitignore
ZStriker19 d10c59f
fix spelling in circleci
ZStriker19 906dd85
fixing formatting
ZStriker19 8fc8596
Remove changes to Dockerfile.buster
ZStriker19 a7a601c
Merge remote-tracking branch 'origin/master' into add_mariadb
ZStriker19 671771b
flake8 formatting
ZStriker19 aaa5d90
Merge branch 'master' into add_mariadb
Kyle-Verhoog 88e7cc1
recreated snapshots and added mariadb to spelling_wordlist
ZStriker19 1b5aae6
Merge branch 'add_mariadb' of github.com:DataDog/dd-trace-py into add…
ZStriker19 59ef781
changing test case so tracer flushes
ZStriker19 ff54feb
changing test case to pass in CI
ZStriker19 8ff94b4
formatting
ZStriker19 5d53d39
Update ddtrace/contrib/mariadb/__init__.py
ZStriker19 cc74fc0
Update ddtrace/contrib/mariadb/__init__.py
ZStriker19 83d5e01
snapshots
ZStriker19 9172168
Merge branch 'add_mariadb' of github.com:DataDog/dd-trace-py into add…
ZStriker19 3cd4893
updating tests so connection closes on each
ZStriker19 82f47fc
Extend environment instead of replacing it
Kyle-Verhoog e567e5f
fix formatting and refactor a bit in tests
ZStriker19 64dfb74
Update ddtrace/contrib/mariadb/__init__.py
ZStriker19 e521fe4
Merge branch 'master' into add_mariadb
Kyle-Verhoog c373a38
formatting
ZStriker19 6baf6e7
formatting
ZStriker19 10b19e5
Merge branch 'master' into add_mariadb
mergify[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| """ | ||
| The MariaDB integration instruments the | ||
| `MariaDB library <https://mariadb-corporation.github.io/mariadb-connector-python/usage.html>`_ to trace queries. | ||
|
|
||
|
|
||
| Enabling | ||
| ~~~~~~~~ | ||
|
|
||
| The MariaDB integration is enabled automatically when using | ||
| :ref:`ddtrace-run<ddtracerun>` or :ref:`patch_all()<patch_all>`. | ||
|
|
||
| Or use :ref:`patch()<patch>` to manually enable the integration:: | ||
|
|
||
| from ddtrace import patch | ||
| patch(mariadb=True) | ||
|
|
||
|
|
||
| Global Configuration | ||
| ~~~~~~~~~~~~~~~~~~~~ | ||
|
|
||
| .. py:data:: ddtrace.config.mariadb["service"] | ||
|
|
||
| The service name reported by default for MariaDB spans. | ||
|
|
||
| This option can also be set with the ``DD_MARIADB_SERVICE`` environment | ||
| variable. | ||
|
|
||
| Default: ``"mariadb"`` | ||
|
|
||
|
|
||
| Instance Configuration | ||
| ~~~~~~~~~~~~~~~~~~~~~~ | ||
|
|
||
| To configure the mariadb integration on an per-connection basis use the | ||
| ``Pin`` API:: | ||
|
|
||
| from ddtrace import Pin | ||
| from ddtrace import patch | ||
|
|
||
| # Make sure to patch before importing mariadb | ||
| patch(mariadb=True) | ||
|
|
||
| import mariadb.connector | ||
|
|
||
| # This will report a span with the default settings | ||
| conn = mariadb.connector.connect(user="alice", password="b0b", host="localhost", port=3306, database="test") | ||
|
|
||
| # Use a pin to override the service name for this connection. | ||
| Pin.override(conn, service="mariadb-users") | ||
|
|
||
| cursor = conn.cursor() | ||
| cursor.execute("SELECT 6*7 AS the_answer;") | ||
|
|
||
| """ | ||
| from ...utils.importlib import require_modules | ||
|
|
||
|
|
||
| required_modules = ["mariadb"] | ||
|
|
||
| with require_modules(required_modules) as missing_modules: | ||
| if not missing_modules: | ||
| from .patch import patch | ||
| from .patch import unpatch | ||
|
|
||
| __all__ = ["patch", "unpatch"] |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| import mariadb | ||
|
|
||
| from ddtrace import Pin | ||
| from ddtrace import config | ||
| from ddtrace.contrib.dbapi import TracedConnection | ||
| from ddtrace.ext import db | ||
| from ddtrace.ext import net | ||
| from ddtrace.utils.formats import asbool | ||
| from ddtrace.utils.formats import get_env | ||
| from ddtrace.utils.wrappers import unwrap | ||
| from ddtrace.vendor import wrapt | ||
|
|
||
|
|
||
| config._add( | ||
| "mariadb", | ||
| dict( | ||
| trace_fetch_methods=asbool(get_env("mariadb", "trace_fetch_methods", default=False)), | ||
| _default_service="mariadb", | ||
| ), | ||
| ) | ||
|
|
||
|
|
||
| def patch(): | ||
| if getattr(mariadb, "_datadog_patch", False): | ||
| return | ||
| setattr(mariadb, "_datadog_patch", True) | ||
| wrapt.wrap_function_wrapper("mariadb", "connect", _connect) | ||
|
|
||
|
|
||
| def unpatch(): | ||
| if getattr(mariadb, "_datadog_patch", False): | ||
| setattr(mariadb, "_datadog_patch", False) | ||
| unwrap(mariadb, "connect") | ||
|
|
||
|
|
||
| def _connect(func, instance, args, kwargs): | ||
| conn = func(*args, **kwargs) | ||
| tags = { | ||
| net.TARGET_HOST: kwargs["host"], | ||
| net.TARGET_PORT: kwargs["port"], | ||
| db.USER: kwargs["user"], | ||
| db.NAME: kwargs["database"], | ||
| } | ||
|
|
||
| pin = Pin(app="mariadb", tags=tags) | ||
|
|
||
| wrapped = TracedConnection(conn, pin=pin, cfg=config.mariadb) | ||
| pin.onto(wrapped) | ||
| return wrapped | ||
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -72,6 +72,7 @@ kwarg | |
| lifecycle | ||
| lookups | ||
| mako | ||
| mariadb | ||
| memcached | ||
| metadata | ||
| microservices | ||
|
|
||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| --- | ||
| features: | ||
| - | | ||
| Add MariaDB integration. |
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
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
Empty file.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.