Skip to content

Add support for test.codeowners and test.source.* tags#4597

Merged
nikita-tkachenko-datadog merged 24 commits into
masterfrom
nikita-tkachenko/codeowners
Feb 1, 2023
Merged

Add support for test.codeowners and test.source.* tags#4597
nikita-tkachenko-datadog merged 24 commits into
masterfrom
nikita-tkachenko/codeowners

Conversation

@nikita-tkachenko-datadog

Copy link
Copy Markdown
Contributor

What Does This Do

This PR updates CI-visibility part of the tracer, adding support for the following tags:

test.codeowners: teams/people who own the test (in accordance with the CODEOWNERS file, if one is available in the client's repo)
test.source.file: file path where the test is located, relative to the project's source root
test.source.start: the line in the test source file where the test definition starts
test.source.end: the line of the source code where the test ends

Motivation

These tags are part of the CI visibility tracers specification.
Populating them will allow the clients to use additional features offered by CI visibility: showing source code, notifying code owners about test failures, etc.

Additional Notes

In scope of this PR a new gradle module was created for logic that is specific to CI visibility: dd-java-agent:agent-ci-visibility.
For now, in order to keep the scope of the PR smaller, the new module only contains logic introduced to support the codeowners/source tag features.
The intention is to later move all the CI visibility logic to the new module, with only the interfaces remaining in internal-api module - that way CI visibility will be consistent with the other subsystems residing in the tracer.

@nikita-tkachenko-datadog nikita-tkachenko-datadog added the comp: ci visibility Continuous Integration Visibility label Jan 25, 2023
@nikita-tkachenko-datadog nikita-tkachenko-datadog changed the title Nikita tkachenko/codeowners Add support for test.codeowners and test.source.* tags Jan 25, 2023
@nikita-tkachenko-datadog
nikita-tkachenko-datadog marked this pull request as ready for review January 25, 2023 16:31
public @Nullable Collection<String> getOwners(String path) {
if (!path.startsWith(repoRoot)) {
return Collections.emptyList();
return null;

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.

What was the reason using null ?
I'd rather keep empty list to avoid possible NPE.

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.

The idea was to use an empty list for files that have no owners (it's possible to have a CODEOWNERS entry that says file/folder is not owned by anyone), and null for the cases when owners could not be determined.

Anyway, this looks like an older version of the code - this PR has a bunch of commits that I will squash during merge - in the PR's last commit this code looks a bit different.


@Nullable
@Override
public String getSourcePath(Class<?> c) {

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.

I think, there is missing null checker for Class<?> c

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.

From my point of view an appropriate response to getSourcePath(null) would be an NPE, since this likely indicates a programming error, which is best signalled in a fail-fast manner. Swallowing a null argument might cover this sort of programming issues, making them harder to discover.
Currently this method will never be called with a null argument, as the calling code does the necessary checks.

@nikita-tkachenko-datadog

Copy link
Copy Markdown
Contributor Author

@ValentinZakharov, thank you for the review!

@nikita-tkachenko-datadog
nikita-tkachenko-datadog merged commit 5fc82d6 into master Feb 1, 2023
@nikita-tkachenko-datadog
nikita-tkachenko-datadog deleted the nikita-tkachenko/codeowners branch February 1, 2023 10:52
@github-actions github-actions Bot added this to the 1.7.0 milestone Feb 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp: ci visibility Continuous Integration Visibility

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants