Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ endif::[]
===== Features
* Add backend granularity data to SQL backends as well as Cassandra and pymongo {pull}1585[#1585], {pull}1639[#1639]
* Add support for instrumenting the Elasticsearch 8 Python client {pull}1642[#1642]
* Add `*principal*` to default `sanitize_field_names` configuration {pull}1664[#1664]
* Add docs and better support for custom metrics, including in AWS Lambda {pull}1643[#1643]

[float]
Expand Down
1 change: 1 addition & 0 deletions docs/configuration.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -876,6 +876,7 @@ WARNING: We recommend always including the default set of validators if you cust
"*credit*",
"*card*",
"*auth*",
"*principal*",
"set-cookie"]`
|============

Expand Down
13 changes: 5 additions & 8 deletions elasticapm/conf/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,17 @@
import decimal
import re
from collections import namedtuple
from typing import Pattern


def _starmatch_to_regex(pattern):
def _starmatch_to_regex(pattern: str) -> Pattern:
"""
This is a duplicate of starmatch_to_regex() in utils/__init__.py

Duplication to avoid circular imports
"""
options = re.DOTALL
# check if we are case sensitive
# check if we are case-sensitive
if pattern.startswith("(?-i)"):
pattern = pattern[5:]
else:
Expand Down Expand Up @@ -98,6 +99,7 @@ def _starmatch_to_regex(pattern):
"*credit*",
"*card*",
"*auth*",
"*principal*",
"set-cookie",
]

Expand All @@ -107,12 +109,7 @@ def _starmatch_to_regex(pattern):
SUCCESS="success", FAILURE="failure", UNKNOWN="unknown"
)

try:
# Python 2
LABEL_TYPES = (bool, int, long, float, decimal.Decimal)
except NameError:
# Python 3
LABEL_TYPES = (bool, int, float, decimal.Decimal)
LABEL_TYPES = (bool, int, float, decimal.Decimal)

TRACESTATE = namedtuple("TRACESTATE", ["SAMPLE_RATE"])(SAMPLE_RATE="s")
TRACE_CONTINUATION_STRATEGY = namedtuple("TRACE_CONTINUATION_STRATEGY", ["CONTINUE", "RESTART", "RESTART_EXTERNAL"])(
Expand Down
2 changes: 1 addition & 1 deletion elasticapm/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ def read_pem_file(file_obj) -> bytes:

def starmatch_to_regex(pattern: str) -> Pattern:
options = re.DOTALL
# check if we are case sensitive
# check if we are case-sensitive
if pattern.startswith("(?-i)"):
pattern = pattern[5:]
else:
Expand Down
3 changes: 3 additions & 0 deletions tests/processors/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ def http_test_data():
"authorization": "bearer xyz",
"some-header": "some-secret-value",
"cookie": "foo=bar; baz=foo",
"Ms-Client-Principal-Id": "foo",
},
"cookies": {
"foo": "bar",
Expand All @@ -85,6 +86,7 @@ def http_test_data():
"authorization": "bearer xyz",
"some-header": "some-secret-value",
"cookie": "foo=bar; baz=foo",
"Ms-Client-Principal-Id": "foo",
},
},
}
Expand Down Expand Up @@ -296,6 +298,7 @@ def test_sanitize_http_headers(elasticapm_client, custom_header, http_test_data)
"password": processors.MASK,
"secret": processors.MASK,
"authorization": processors.MASK,
"Ms-Client-Principal-Id": processors.MASK,
}
expected.update(custom_header)
assert result["context"]["request"]["headers"] == expected
Expand Down