Skip to content

feat: enhance the support for dropping filter#288

Merged
kotharironak merged 7 commits intomainfrom
enhancing-drop-criteria
Nov 23, 2021
Merged

feat: enhance the support for dropping filter#288
kotharironak merged 7 commits intomainfrom
enhancing-drop-criteria

Conversation

@kotharironak
Copy link
Copy Markdown
Contributor

@kotharironak kotharironak commented Nov 18, 2021

Description

This PR, enhance the support for dropping the span at entry-level. There are certain issues in the existing one.

  • It only supports equal operation
  • it's not easily readable
  • uses a certain string delimiter making its error-prone

e.g of existing drop filter criteria
["k1:v1, k2:v2", "k3:v3]

As we can see, it is supported as an array of strings that are considered as OR expressions. The string supports AND operation via :.

New Approach:

  • It will be readable JSON structure
  • will supports EQ, CONTAINS, EXISTS and NEQ operator

e.g

[
	[
		{
			"tagKey": "http.path",
			"operator": "EQ",
			"tagValue": "abcdef"
		},
		{
			"tagKey": "http.url",
			"operator": "CONTAINS",
			"tagValue": "val"
		},
		{
			"tagKey": "grpc.tag",
			"operator": "EXISTS"
		}
	],
	[
		{
		"tagKey": "tenant-id",
		"operator": "EQ",
		"tagValue": "xyz"
		}
	]
]

As it can be seen, its array of OR (AND [Filters]) expression.

Testing

Added unit tests and extended topology test driver test too

Checklist:

  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • Any dependent changes have been merged and published in downstream modules

@kotharironak
Copy link
Copy Markdown
Contributor Author

@avinashkolluru @satish-mittal @ravisingal This PR extends the new approach. Once, this will be available, the existing one will be removed as follow-up PR.

@github-actions

This comment has been minimized.

@codecov
Copy link
Copy Markdown

codecov Bot commented Nov 18, 2021

Codecov Report

Merging #288 (8b73714) into main (431d690) will increase coverage by 0.24%.
The diff coverage is 89.09%.

Impacted file tree graph

@@             Coverage Diff              @@
##               main     #288      +/-   ##
============================================
+ Coverage     79.20%   79.44%   +0.24%     
- Complexity     1239     1265      +26     
============================================
  Files           111      112       +1     
  Lines          4880     4934      +54     
  Branches        442      452      +10     
============================================
+ Hits           3865     3920      +55     
+ Misses          813      812       -1     
  Partials        202      202              
Flag Coverage Δ
unit 79.44% <89.09%> (+0.24%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...ace/core/spannormalizer/jaeger/SpanDropFilter.java 88.88% <88.88%> (ø)
...ertrace/core/spannormalizer/jaeger/SpanFilter.java 88.54% <88.88%> (+0.20%) ⬆️
.../spannormalizer/jaeger/JaegerSpanPreProcessor.java 84.61% <100.00%> (+11.53%) ⬆️
...izer/jaeger/JaegerSpanToLogRecordsTransformer.java 91.30% <0.00%> (+2.17%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 431d690...8b73714. Read the comment docs.

@github-actions

This comment has been minimized.

switch (filter.getOperator()) {
case EQ:
return tags.containsKey(filter.getTagKey())
&& StringUtils.equals(tags.get(filter.getTagKey()).getVStr(), filter.getTagValue());
Copy link
Copy Markdown
Contributor

@avinashkolluru avinashkolluru Nov 23, 2021

Choose a reason for hiding this comment

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

@kotharironak We may have to look into the process tags too. See below

  public Optional<String> getTenantId(
      Map<String, KeyValue> spanTags, Map<String, KeyValue> processTags) {
    return Optional.ofNullable(processTags.get(tenantIdKey))
        .or(() -> Optional.ofNullable(spanTags.get(tenantIdKey)))
        .map(KeyValue::getVStr);
  }

cc: @laxman-traceable @ravisingal

Copy link
Copy Markdown
Contributor Author

@kotharironak kotharironak Nov 23, 2021

Choose a reason for hiding this comment

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

I think the process tags are meant for resources, do we want to drop span based on resource criteria? So, far we are dropping based on span attribute filters, and with that, we are able to filter existing scenarios, right? Are there some scenario?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@ravisingal @avinashkolluru I have added the support for processTags too. So, now the filter will check in the union of two tags (processTags, spanTags).

Total Tags = Process Tags + Span Tags will be used for matching a filter.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.


if (anySpanDropFiltersMatch(spanDropFilters, tags, processTags)) {
if (DROPPED_SPANS_RATE_LIMITER.tryAcquire()) {
LOG.info("Dropping span: [{}] with drop filters: [{}]", span, spanDropFilters);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This will log too much. I think we should move this to debug. Even above it should move to debug.
I'm assuming once we migrate the configs to this new format, we'll get rid of the above.

Copy link
Copy Markdown
Contributor Author

@kotharironak kotharironak Nov 23, 2021

Choose a reason for hiding this comment

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

Done.
Screenshot 2021-11-23 at 8 38 35 PM

.collect(Collectors.toList());
})
.collect(Collectors.toList());
LOG.info("Json String for Span drop criterion: {}", this.spanDropFilters);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

toString() missing in SpanDropFilter class

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Its not a Json right?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

No, it is List<List>, move the logging in the top before parsing in case of any failure we know what has failed.

Copy link
Copy Markdown
Contributor Author

@kotharironak kotharironak Nov 23, 2021

Choose a reason for hiding this comment

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

Done
Screenshot 2021-11-23 at 8 18 04 PM

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

}

if (anySpanDropFiltersMatch(spanDropFilters, tags, processTags)) {
if (DROPPED_SPANS_RATE_LIMITER.tryAcquire()) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: can you put this block inside a debugger enabled check?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

There is to string not any eval, should it still matter?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Wanted to avoid the extra ratelimiter check

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ah! I see b'cause of tryAcquire, can do this.

@github-actions

This comment has been minimized.

@kotharironak kotharironak merged commit efa5d17 into main Nov 23, 2021
@kotharironak kotharironak deleted the enhancing-drop-criteria branch November 23, 2021 16:24
@github-actions
Copy link
Copy Markdown

Unit Test Results

  74 files  ±0    74 suites  ±0   1m 4s ⏱️ -3s
392 tests +3  392 ✔️ +3  0 💤 ±0  0 ❌ ±0 

Results for commit efa5d17. ± Comparison against base commit 431d690.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants