Skip to content

Instantly share code, notes, and snippets.

@mariusoe
Created December 15, 2021 15:18
Show Gist options
  • Save mariusoe/865b8307ac37c9efc9af984c0553f2de to your computer and use it in GitHub Desktop.
Save mariusoe/865b8307ac37c9efc9af984c0553f2de to your computer and use it in GitHub Desktop.
inspectIT Ocelot - Extention for excluding specific URLs from tracing
inspectit:
instrumentation:
actions:
# Checks if the given input string fully matches any of the provided regexes.
# If it does, the matched regex is returned. Otherwise, null is returned.
#
# the patterns are expected to be a list of the following form:
# constant-input:
# patterns:
# - <regexA>
# - <regexB>
'a_regex_matchesAny':
imports:
- 'java.util'
- 'java.util.regex'
input:
'string': 'String'
'patterns': 'Map'
value-body: |
if (string == null) {
return null;
}
for (int i = 0; i < patterns.size(); i++) {
String pattern = (String) patterns.get(String.valueOf(i));
Pattern regex = Pattern.compile(pattern);
Matcher m = regex.matcher(string);
if (m.matches()) {
return pattern;
}
}
return null;
rules:
'r_servletapi_tracing':
include:
'r_http_tracing_excludes': true
tracing:
sample-probability: 'sample_probability'
entry:
'sample_probability':
only-if-not-null: 'http_tracing_exclude_match'
action: a_assign_value
constant-input:
'value': 0.0
'r_http_tracing_excludes': {}
inspectit:
instrumentation:
rules:
'r_http_tracing_excludes':
include:
'r_custom_excludes': true
'r_custom_excludes':
entry:
'http_tracing_exclude_match':
only-if-null: 'http_tracing_exclude_match'
action: 'a_regex_matchesAny'
data-input:
'string': 'http_path'
constant-input:
'patterns':
- '.*\/spring\/health.*'
- '.*\/actuator\/.*'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment