-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add setSqlBody tracing helper (#957)
Make it easier to set SQL queries as the span body attribute without danger of storing unsanitized SQL queries. When `setSqlBody` is used in combination with `setBody`, the `setSqlBody` call is leading. Related to appsignal/appsignal-python#140 This change was made available in the agent in PR #955 Part of #956
- Loading branch information
Showing
3 changed files
with
31 additions
and
4 deletions.
There are no files selected for viewing
This file contains 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,18 @@ | ||
--- | ||
bump: "patch" | ||
type: "add" | ||
--- | ||
|
||
Add the `setSqlBody` tracing helper to set the body attribute on a span that contains a SQL query. When using this helper the given SQL query will be sanitized, reducing the chances of sending sensitive data to AppSignal. | ||
|
||
```js | ||
import { setSqlBody } from "@appsignal/nodejs"; | ||
|
||
// Must be used in an instrumented context -- e.g. an Express route | ||
setSqlBody("SELECT * FROM users WHERE 'password' = 'secret'"); | ||
// Will be stored as: "SELECT * FROM users WHERE 'password' = ?" | ||
``` | ||
|
||
When the `setBody` helper is also used, the `setSqlBody` overwrites the `setBody` attribute. | ||
|
||
More information about our [tracing helpers](https://docs.appsignal.com/nodejs/3.x/instrumentation/instrumentation.html) can be found in our documentation. |
This file contains 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 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