dd-trace-py icon indicating copy to clipboard operation
dd-trace-py copied to clipboard

feat(snowflake): add snowflake query id tag

Open shahargl opened this issue 2 years ago • 3 comments

Description

We are using snowflake as our database and wanted to add a tag that represents the "query id" so we will be able to look for it later in snowflake.

For example, the query id in snowflake is called "sfqid" and returned after the query executed. So in this example, I've added "sfqid" with value None to the Pin inside snowflake/patch.py, and then after the query execution I'm populating the value of this tag (inside dbapi/init.py)

image

Now I can take this sfqid and look for it in the Database image

Checklist

Motivation

Add the ability to "inject" tags that are available only after the query done (like rows_count).

Design

I'm using the fact that Pin is a dictionary of tags that being passed to the dbapi, to inject tags with None value that will later be populated.

Testing strategy

The feature is working and currently snowflake spans gets "sfqid"'s.

Reviewer Checklist

  • [ ] Title is accurate.
  • [ ] Description motivates each change.
  • [ ] No unnecessary changes were introduced in this PR.
  • [ ] PR cannot be broken up into smaller PRs.
  • [ ] Avoid breaking API changes unless absolutely necessary.
  • [ ] Tests provided or description of manual testing performed is included in the code or PR.
  • [ ] Release note has been added for fixes and features, or else changelog/no-changelog label added.
  • [ ] All relevant GitHub issues are correctly linked.
  • [ ] Backports are identified and tagged with Mergifyio.
  • [ ] Add to milestone.

shahargl avatar Aug 10 '22 08:08 shahargl

@mabdinur I've tried to add changelog and merge from 1.x but I don't have permission to push to this repository. What should I do now?

shahargl avatar Aug 10 '22 08:08 shahargl

@mabdinur I've tried to add changelog and merge from 1.x but I don't have permission to push to this repository. What should I do now?

Sorry I should've proposed these changes on your ddtrace fork. I added a release note and made some minor tweaks to the snapshots. This pull request looks good to me but you'll need one more approval before it can be merged.

mabdinur avatar Aug 10 '22 19:08 mabdinur

So we are waiting for another approval? exciting :)

shahargl avatar Aug 11 '22 12:08 shahargl

any news?

shahargl avatar Aug 22 '22 08:08 shahargl

Codecov Report

Merging #4069 (935388b) into 1.x (a940ef1) will decrease coverage by 0.05%. The diff coverage is 44.80%.

@@            Coverage Diff             @@
##              1.x    #4069      +/-   ##
==========================================
- Coverage   78.86%   78.80%   -0.06%     
==========================================
  Files         720      720              
  Lines       57386    57511     +125     
==========================================
+ Hits        45255    45323      +68     
- Misses      12131    12188      +57     
Impacted Files Coverage Δ
ddtrace/contrib/flask/patch.py 0.00% <0.00%> (ø)
tests/contrib/django/django1_app/urls.py 100.00% <ø> (ø)
tests/contrib/django/django_app/urls.py 92.59% <ø> (ø)
tests/contrib/flask/app.py 0.00% <0.00%> (ø)
tests/contrib/flask/test_flask_appsec.py 0.00% <0.00%> (ø)
tests/contrib/snowflake/test_snowflake.py 94.18% <ø> (ø)
tests/internal/test_module.py 0.00% <0.00%> (ø)
tests/profiling/collector/test_threading.py 0.00% <0.00%> (ø)
tests/profiling/collector/test_traceback.py 0.00% <0.00%> (ø)
tests/tracer/test_forksafe.py 69.76% <9.09%> (-11.01%) :arrow_down:
... and 13 more

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more

codecov-commenter avatar Aug 23 '22 14:08 codecov-commenter

@Mergifyio refresh

brettlangdon avatar Aug 23 '22 15:08 brettlangdon

refresh

✅ Pull request refreshed

mergify[bot] avatar Aug 23 '22 15:08 mergify[bot]