Skip to content

Conversation

@nikita-tkachenko-datadog
Copy link
Contributor

@nikita-tkachenko-datadog nikita-tkachenko-datadog commented Mar 23, 2023

What Does This Do

Adds a new component that reads Git metadata from git.properties file available on the system classpath (clients can configure their Gradle/Maven build to use 3rd-party plugins that embed this file into their JARs).
The obtained metadata is then used the following way:

  • when trace telemetry is sent, the metadata is added to the first span of each trace
  • when profile telemetry is sent, the metadata is added to each profile

Motivation

This is needed to simplify configuration for clients and to make using Source-Code Integration features easier.
More info can be found in the RFC and the Jira task.

Additional Notes

  • a similar logic to obtain Git metadata was implemented previously in the CI Visibility part of the tracer. That logic was refactored in this PR to work on top of the central solution (there is a "registry" of Git metadata builders, of which two are generally available and two are specific to CI Visibility and are only registered when CI Visibility is enabled)
  • adding git metadata to trace telemetry has been implemented via TraceInterceptor mechanism. Using it previously was somewhat error-prone as each interceptor was required to have a unique integer "priority". Ensuring priority uniqueness was difficult as interceptors were scattered across different modules (moreover, clients were capable of injecting their own interceptors). A few minor improvements were done in this PR to alleviate this: priorities of "standard" interceptors were centralised in an enum, and an error log message was added to highlight attempts to register interceptors with the same priority.

return GitInfo.NOOP;
}
return new LocalFSGitInfoExtractor()
.headCommit(Paths.get(repositoryPath, gitFolderName).toFile().getAbsolutePath());

Check failure

Code scanning / CodeQL

Uncontrolled data used in path expression

[User-provided value](1) flows to here and is used in a path. [User-provided value](2) flows to here and is used in a path. [User-provided value](3) flows to here and is used in a path. [User-provided value](4) flows to here and is used in a path. [User-provided value](5) flows to here and is used in a path. [User-provided value](6) flows to here and is used in a path. [User-provided value](7) flows to here and is used in a path. [User-provided value](8) flows to here and is used in a path.
public class CIProviderGitInfoBuilder implements GitInfoBuilder {
@Override
public GitInfo build(@Nullable String repositoryPath) {
Path currentPath = repositoryPath != null ? Paths.get(repositoryPath) : null;

Check failure

Code scanning / CodeQL

Uncontrolled data used in path expression

[User-provided value](1) flows to here and is used in a path. [User-provided value](2) flows to here and is used in a path. [User-provided value](3) flows to here and is used in a path. [User-provided value](4) flows to here and is used in a path. [User-provided value](5) flows to here and is used in a path. [User-provided value](6) flows to here and is used in a path. [User-provided value](7) flows to here and is used in a path. [User-provided value](8) flows to here and is used in a path.
@nikita-tkachenko-datadog nikita-tkachenko-datadog changed the title WIP: Implement embedded git metadata extraction Implement embedded git metadata extraction Mar 23, 2023
@nikita-tkachenko-datadog nikita-tkachenko-datadog force-pushed the nikita-tkachenko/source-code-integration-git-info branch from d75e63d to 2e8f19a Compare March 23, 2023 21:25
@nikita-tkachenko-datadog nikita-tkachenko-datadog force-pushed the nikita-tkachenko/source-code-integration-git-info branch from d935208 to 94d72ec Compare March 28, 2023 12:14
@nikita-tkachenko-datadog nikita-tkachenko-datadog marked this pull request as ready for review March 28, 2023 14:02
Copy link

@sashacmc sashacmc left a comment

Choose a reason for hiding this comment

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

Some small notes, overall LGTM!

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants