Skip to content

Nocode class and method selectors #2304

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

Merged
merged 22 commits into from
Jun 3, 2025
Merged

Conversation

johnbley
Copy link
Contributor

@johnbley johnbley commented May 13, 2025

Add logic for more complex class/method selectors than just exact-name-matching:

  • and
  • or
  • not
  • hasSuperType
  • named
  • nameMatches (regex)
  • hasParameterCount
  • hasParameterOfType (index, type)

I tried to keep the list/complexity as small as possible while still accounting for 95%+ of real-world usage. I had to add a separate -testing module to work around a classloader issue in order to properly test all the invalid parse logic.

A larger classloader problem I encountered was that the yaml is clearly specifying bytebuddy ElementMatchers (and the logic for producing and using them is pretty clean since the feature set offered by bytebuddy is so complete), but bytebuddy classes are not visible to the bootstrap-located Rule class. Rather than wrap the ElementMatcher logic in a bootstrap-only shim class, for now I'm exposing them as simple Objects (with some comments) since they are never used or invoked at the bootstrap layer. It's not a great design, and I'm happy to code up anything better that anybody else comes up with. Lauri suggested a fix separating a bootstrap interface for Rule from a RuleImpl in agent space which can safely reference the ElementMatcher directly. Thanks, Lauri!

@johnbley johnbley requested review from a team as code owners May 13, 2025 13:29
@robsunday
Copy link
Contributor

And one more question. YAML files for declarative config use snake case naming convention, rather than camelCase. Maybe we should use the same?

@johnbley
Copy link
Contributor Author

And one more question. YAML files for declarative config use snake case naming convention, rather than camelCase. Maybe we should use the same?

Good call. I updated all the old stuff to snake_case too (e.g., span_status instead of spanStatus, and touched up the docs as well.

…instrumentation/nocode/NocodeInitializer.java

Co-authored-by: Lauri Tulmin <[email protected]>

// formatting of the strings with newlines makes it easier to read and
// reason about the test.
// spotless:off
Copy link
Collaborator

Choose a reason for hiding this comment

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

an alternative that could be considered would be to use text blocks since the tests run with java 17

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll see what's available when I reformat this whole thing for -contrib.

}
};

abstract <E extends NamedElement> ElementMatcher<E> parse(
Copy link
Collaborator

@laurit laurit Jun 3, 2025

Choose a reason for hiding this comment

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

I'll change the return type to ElementMatcher<? extends NamedElement>. This will push the unchecked cast to the caller of the parse method in matcherFromKeyAndYamlValue.

@johnbley johnbley merged commit 9127cc2 into signalfx:main Jun 3, 2025
26 checks passed
@johnbley johnbley deleted the nocode_selectors branch June 3, 2025 17:23
@github-actions github-actions bot locked and limited conversation to collaborators Jun 3, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants