Skip to content

feat: transaction_ignore_urls wildcard matching#1876

Merged
astorm merged 1 commit intomasterfrom
astorm/transaction-ignore-url-wildcard
Nov 19, 2020
Merged

feat: transaction_ignore_urls wildcard matching#1876
astorm merged 1 commit intomasterfrom
astorm/transaction-ignore-url-wildcard

Conversation

@astorm
Copy link
Copy Markdown
Contributor

@astorm astorm commented Nov 17, 2020

Will Fix: #1689

Implements ELASTIC_TRANSACTION_IGNORE_URL/transactionIgnoreUrls configuration for wildcard URL ignoring. The intent of this new configuration is to gives users the ability to skip generating transactions for a request to a URL that matches an exact string, or a URL that matches simple wildcard pattern. This wildcard pattern will behave consistently across language agents.

This PR leaves the existing ignoreUrls configuration in place to allow users access to more powerful regular expression matching and to preserve existing functionality for users using this older configuration setting.

This PR also introduces a new dependency, escape-string-regexp. In order to implement the suggested wildcard matching algorithm we needed the ability to escape a string for use in a regular expression. Since Node.js doesn't have this functionality natively, I pulled in escape-string-regexp rather than attempt to write (easy) and maintain (harder) this functionality ourselves. Happy to revisit this decision if we'd rather implement this functionality ourselves.

Open items for consideration/completion

  • is escape-string-regexp an acceptable dependency for ignore regular expressions?
  • Docs
  • Fixture downloading
  • central config handling? How does this work in Node Agent, do we need more here?
  • should leading / be assumed? (we'll prepend this, meaning a configured value of 'foo*' and '/foo*' will match the same)
  • need clarity on (?-i) and (?+i) prefixes across agents
  • Does this apply only to transactions? (yes, isRequestBlacklisted is only called in instrumentRequest, and instrumentRequest is only used when wrapping http(s).Server's emit method (i.e. it's used in transaction starting)

Checklist

  • Implement code
  • Add tests
  • Update TypeScript typings
  • Update documentation
  • Commit message follows commit guidelines

@astorm astorm requested review from bmorelli25 and trentm November 17, 2020 00:51
@astorm astorm force-pushed the astorm/transaction-ignore-url-wildcard branch from 8706e62 to a85320a Compare November 17, 2020 00:59
Copy link
Copy Markdown
Member

@bmorelli25 bmorelli25 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! One small typo, otherwise docs LGTM 🎉

@astorm astorm force-pushed the astorm/transaction-ignore-url-wildcard branch 2 times, most recently from 9830a26 to cd82d99 Compare November 17, 2020 01:50
@ghost
Copy link
Copy Markdown

ghost commented Nov 17, 2020

💚 Build Succeeded

the below badges are clickable and redirect to their specific view in the CI or DOCS
Pipeline View Test View Changes Artifacts preview

Expand to view the summary

Build stats

  • Build Cause: [Pull request #1876 updated]

  • Start Time: 2020-11-19T17:13:51.359+0000

  • Duration: 16 min 55 sec

Test stats 🧪

Test Results
Failed 0
Passed 16398
Skipped 0
Total 16398

@astorm astorm force-pushed the astorm/transaction-ignore-url-wildcard branch from f8911e9 to 887a4fc Compare November 19, 2020 17:13
@trentm trentm self-requested a review November 19, 2020 19:53
Copy link
Copy Markdown
Member

@trentm trentm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a spelling typo in the docs and a typo. Soft approving.


Array or comma-separated string used to restrict requests for certain URLs from being instrumented.

This property should be set to an array containing one or more string patterns.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Could probably drop this sentence given the one before it?

When an incoming HTTP request is detected, its URL pathname will be tested against each element
in this list. The `transactionIgnoreUrls` property supports exact string matches,
simple wildcard (`*`) matches, and may not include commas. Wildcard matches are
case insensative by default. You may make wildcard searches case sensative by
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
case insensative by default. You may make wildcard searches case sensative by
case-insensitive by default. You may make wildcard searches case-sensitive by

*/
const escapeStringRegexp = require('escape-string-regexp')

// coverts elastic-wildcard pattern into a
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit:

Suggested change
// coverts elastic-wildcard pattern into a
// Converts elastic-wildcard pattern into a

@astorm astorm added the agent-nodejs Make available for APM Agents project planning. label Nov 19, 2020
@astorm
Copy link
Copy Markdown
Contributor Author

astorm commented Nov 19, 2020

Merging, and will handle the docs typos in a quick follow-on PR.

@astorm astorm merged commit 727c05d into master Nov 19, 2020
@astorm astorm deleted the astorm/transaction-ignore-url-wildcard branch November 19, 2020 23:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent-nodejs Make available for APM Agents project planning.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement transaction_ignore_urls

3 participants