Skip to content
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

Deprecate IGNORE_URLS and replace with TRANSACTION_IGNORE_URLS #811

Merged
merged 6 commits into from Sep 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 6 additions & 3 deletions docs/configuration.asciidoc
Expand Up @@ -258,12 +258,12 @@ server versions.

[float]
[[config-ignore-urls]]
=== `ELASTIC_APM_IGNORE_URLS`
=== `ELASTIC_APM_TRANSACTION_IGNORE_URLS`

[options="header"]
|============
| Environment | Default | Example
| `ELASTIC_APM_IGNORE_URLS` | | `/heartbeat*, *.jpg`
| Environment | Default | Example
| `ELASTIC_APM_TRANSACTION_IGNORE_URLS` | | `/heartbeat*, *.jpg`
|============

A list of patterns to match HTTP requests to ignore. An incoming HTTP request
Copy link
Member

Choose a reason for hiding this comment

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

Can you please add a note below that we'll continue to support "ELASTIC_APM_IGNORE_URLS", and that it's deprecated and will be removed in a future release

Expand All @@ -273,6 +273,9 @@ This option supports the wildcard `*`, which matches zero or more characters.
Examples: `/foo/*/bar/*/baz*`, `*foo*`. Matching is case insensitive by default.
Prefixing a pattern with `(?-i)` makes the matching case sensitive.

NOTE: this configuration was previously known as `ELASTIC_APM_IGNORE_URLS`, which has been deprecated and will be removed in a future major
version of the agent.

[float]
[[config-sanitize-field-names]]
=== `ELASTIC_APM_SANITIZE_FIELD_NAMES`
Expand Down
8 changes: 6 additions & 2 deletions module/apmhttp/ignorer.go
Expand Up @@ -27,7 +27,8 @@ import (
)

const (
envIgnoreURLs = "ELASTIC_APM_IGNORE_URLS"
envIgnoreURLs = "ELASTIC_APM_TRANSACTION_IGNORE_URLS"
deprecatedEnvIgnoreURLs = "ELASTIC_APM_IGNORE_URLS"
)

var (
Expand All @@ -36,12 +37,15 @@ var (
)

// DefaultServerRequestIgnorer returns the default RequestIgnorer to use in
// handlers. If ELASTIC_APM_IGNORE_URLS is set, it will be treated as a
// handlers. If ELASTIC_APM_TRANSACTION_IGNORE_URLS is set, it will be treated as a
// comma-separated list of wildcard patterns; requests that match any of the
// patterns will be ignored.
func DefaultServerRequestIgnorer() RequestIgnorerFunc {
defaultServerRequestIgnorerOnce.Do(func() {
matchers := configutil.ParseWildcardPatternsEnv(envIgnoreURLs, nil)
if len(matchers) == 0 {
matchers = configutil.ParseWildcardPatternsEnv(deprecatedEnvIgnoreURLs, nil)
}
if len(matchers) != 0 {
defaultServerRequestIgnorer = NewWildcardPatternsRequestIgnorer(matchers)
}
Expand Down
15 changes: 14 additions & 1 deletion module/apmhttp/ignorer_test.go
Expand Up @@ -61,11 +61,24 @@ func testDefaultServerRequestIgnorer(t *testing.T, ignoreURLs string, r *http.Re
if os.Getenv("_INSIDE_TEST") != "1" {
cmd := exec.Command(os.Args[0], "-test.run=^"+regexp.QuoteMeta(t.Name())+"$")
cmd.Env = append(os.Environ(), "_INSIDE_TEST=1")
cmd.Env = append(cmd.Env, "ELASTIC_APM_IGNORE_URLS="+ignoreURLs)
cmd.Env = append(cmd.Env, "ELASTIC_APM_TRANSACTION_IGNORE_URLS="+ignoreURLs)
assert.NoError(t, cmd.Run())
return
}
ignorer := apmhttp.DefaultServerRequestIgnorer()
assert.Equal(t, expect, ignorer(r))
})
}

func TestFallbackDeprecatedRequestIgnorer(t *testing.T) {
if os.Getenv("_INSIDE_TEST") != "1" {
cmd := exec.Command(os.Args[0], "-test.run=^"+regexp.QuoteMeta(t.Name())+"$")
cmd.Env = append(os.Environ(), "_INSIDE_TEST=1")
cmd.Env = append(cmd.Env, "ELASTIC_APM_IGNORE_URLS=*/foo*")
assert.NoError(t, cmd.Run())
return
}
req := &http.Request{URL: &url.URL{Path: "/foo"}}
ignorer := apmhttp.DefaultServerRequestIgnorer()
assert.Equal(t, true, ignorer(req))
}