Skip to content

Conversation

@cleverchuk
Copy link
Contributor

Context:

Span stacktrace filter now checks key presence instead of limiting to only string-key values. This type agnostic approach is consistent with current documentation.

Test Plan:

New unit test and regression.

Test services data

  1. e-1712644058766987264
  2. e-1712643928659124224
  3. e-1742334541200846848
  4. e-1777406072376840192

@cleverchuk cleverchuk requested a review from a team as a code owner December 16, 2025 03:09
@cleverchuk cleverchuk requested a review from Copilot December 16, 2025 03:09
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR changes the SpanStacktraceFilter to check for attribute key presence instead of checking for string-typed attribute values. This makes the filter type-agnostic and aligns with the documented behavior.

Key changes:

  • Modified filter logic to check if attribute keys exist regardless of their value types
  • Changed filterAttributes from static to instance field to support proper testing
  • Enhanced test coverage with multiple attribute types (string, long, string arrays, long arrays)

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
SpanStacktraceFilter.java Refactored the test method to check for attribute key presence instead of string attribute values, and changed filterAttributes from static to instance field
SpanStacktraceFilterTest.java Replaced mock-based tests with comprehensive tests covering multiple attribute types and proper setup/teardown


public class SpanStacktraceFilter implements Predicate<ReadableSpan> {
private static final Set<String> filterAttributes = new HashSet<>();
private final Set<String> filterAttributes = new HashSet<>();
Copy link

Copilot AI Dec 16, 2025

Choose a reason for hiding this comment

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

Changing filterAttributes from static to instance field may cause thread safety issues if SpanStacktraceFilter instances are shared across threads. Each call to test() modifies this field. Consider making this field static and using thread-safe operations, or document that instances should not be shared across threads.

Copilot uses AI. Check for mistakes.
Comment on lines 41 to 50
Set<String> attributes =
readableSpan.getAttributes().asMap().keySet().stream()
.map(AttributeKey::getKey)
.collect(Collectors.toSet());
attributes.retainAll(filterAttributes);
return !attributes.isEmpty();
Copy link

Copilot AI Dec 16, 2025

Choose a reason for hiding this comment

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

This implementation creates a new Set and copies all attribute keys on every invocation. For spans with many attributes, this could be inefficient. Consider using a stream-based approach that short-circuits on the first match: filterAttributes.stream().anyMatch(attr -> readableSpan.getAttributes().asMap().keySet().stream().anyMatch(key -> key.getKey().equals(attr)))

Suggested change
Set<String> attributes =
readableSpan.getAttributes().asMap().keySet().stream()
.map(AttributeKey::getKey)
.collect(Collectors.toSet());
attributes.retainAll(filterAttributes);
return !attributes.isEmpty();
return filterAttributes.stream().anyMatch(
attr -> readableSpan.getAttributes().asMap().keySet().stream()
.anyMatch(key -> key.getKey().equals(attr))
);

Copilot uses AI. Check for mistakes.
Copy link
Contributor

Choose a reason for hiding this comment

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

Any merit to this suggestion?

Copy link
Contributor Author

@cleverchuk cleverchuk Dec 17, 2025

Choose a reason for hiding this comment

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

yeah. compute-wise superior and memory-wise inferior in worst case scenario. all round superior actually.

cheempz
cheempz previously approved these changes Dec 16, 2025
Copy link
Contributor

@cheempz cheempz left a comment

Choose a reason for hiding this comment

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

LGTM pending question.

Comment on lines 41 to 50
Set<String> attributes =
readableSpan.getAttributes().asMap().keySet().stream()
.map(AttributeKey::getKey)
.collect(Collectors.toSet());
attributes.retainAll(filterAttributes);
return !attributes.isEmpty();
Copy link
Contributor

Choose a reason for hiding this comment

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

Any merit to this suggestion?

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

Copy link
Contributor

@cheempz cheempz left a comment

Choose a reason for hiding this comment

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

Thanks for the revisit!

@cleverchuk cleverchuk merged commit f9fd5e1 into main Dec 18, 2025
53 of 63 checks passed
@cleverchuk cleverchuk deleted the cc/NH-126126 branch December 18, 2025 01:12
@cleverchuk
Copy link
Contributor Author

merged because lambda-release-test failing is not actual test failure. it's failure to write test results file.

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

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants