-
Notifications
You must be signed in to change notification settings - Fork 129
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
[maven-extension] Capture details on mojo goal executions: deploy:deploy
, spring-boot:build-image
, jib:build
, snyk:test
, snyk:monitor
#146
Conversation
deploy:deploy
and spring-boot:build-image
deploy:deploy
and spring-boot:build-image
maven-extension/src/main/java/io/opentelemetry/maven/handler/DeployDeployHandler.java
Outdated
Show resolved
Hide resolved
maven-extension/src/main/java/io/opentelemetry/maven/OtelExecutionListener.java
Outdated
Show resolved
Hide resolved
maven-extension/src/main/java/io/opentelemetry/maven/OtelExecutionListener.java
Show resolved
Hide resolved
maven-extension/src/main/java/io/opentelemetry/maven/handler/MojoGoalExecutionHandler.java
Outdated
Show resolved
Hide resolved
@kenfinnigan the visibility OTel tracing brings on the flow of the build is amazing! It can greatly help teams optimize their builds. I discover that even for pretty simple projects, it's easy to wrongly configure the chain of goals of a Maven build and have redundant executions of costly goals. Here is an example below of a build just combining a Spring Boot app with Snyk checks, a deploy to a Maven repo, and and the publishing as a docker image. |
deploy:deploy
and spring-boot:build-image
deploy:deploy
, spring-boot:build-image
, jib:build
, snyk:test
, snyk:monitor
@kenfinnigan @trask I have added in the description of this PR all the introduced span attributes with an explanation on the used namespaces ( I have implemented the enrichment for 5 plugin goals in order to have a broad set of use cases. Even if @trask suggested to subdivide the I can easily implement @trask's suggestion with |
👍 on first glance, it may make sense to move |
...extension/src/main/java/io/opentelemetry/maven/handler/AbstractMojoGoalExecutionHandler.java
Outdated
Show resolved
Hide resolved
@@ -0,0 +1,5 @@ | |||
io.opentelemetry.maven.handler.GoogleJibBuildHandler |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about avoiding SPI for our built in handlers? Then we could make them non-public too, just implementation details.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I introduced the SPI after discussing with @kenfinnigan . I see value in allowing Maven plugin authors to add instrumentation for the their plugins (plugin authors being vendors, oss projects or Maven practitioners).
What solution do you have in mind as an alternative to the SPI?
Before implementing the SPI, I used a hardcoded list of handlers, could it be what you had in mind?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah I had meant a list of built in components that is appended to with SPI. I think it satisfies both itches.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done through d393bea . Please review
maven-extension/src/main/java/io/opentelemetry/maven/MavenUtils.java
Outdated
Show resolved
Hide resolved
maven-extension/src/main/java/io/opentelemetry/maven/OtelExecutionListener.java
Outdated
Show resolved
Hide resolved
.startSpan(); | ||
mojoExecution.getLifecyclePhase()); | ||
// enrich spans with MojoGoalExecutionHandler | ||
Optional<MojoGoalExecutionHandler> handler = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't use Optional much in OTel codebases in favor of Nullable. I just noticed I've been forgetting to add nullness checking to this repo like we have in SDK repo, will add that. Can you look into reducing Optional for more consistency with SDK repo? I don't think the usages here are all that different from null checks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the principle "When in Rome, do as the Romans do" :-). I'll replace the usage of Optional
by using @Nullable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Migration from Optional
to @Nullable
done. Please verify
maven-extension/src/main/java/io/opentelemetry/maven/handler/MavenDeployHandler.java
Outdated
Show resolved
Hide resolved
@trask I followed your guidance and we now have |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So sorry I just merged in the change to error prone knowing that it is likely annoying for this PR. If you are able to merge main and fix issues that come up that would be great, otherwise I can do it to this PR tomorrow.
# Conflicts: # maven-extension/src/main/java/io/opentelemetry/maven/OtelExecutionListener.java # maven-extension/src/main/java/io/opentelemetry/maven/OtelUtils.java # maven-extension/src/main/java/io/opentelemetry/maven/semconv/MavenOtelSemanticAttributes.java
…the SPI mechanism
…the SPI mechanism
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks just small points
...sion/src/main/java/io/opentelemetry/maven/handler/MojoGoalExecutionHandlerConfiguration.java
Outdated
Show resolved
Hide resolved
.forEach( | ||
goal -> { | ||
MojoGoalExecutionHandler previousHandler = | ||
mojoGoalExecutionHandlers.put(goal, handler); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Think you can use toMap
since it will throw on duplicate keys
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @anuraaga . Could you please give me more guidance on this one?
I don't catch how I can use stream.collect(Collectors.toMap())
as I have a double loop 👼
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops - yeah didn't think enough about it, stream doesn't seem good for this case
.forEach( | ||
goal -> { | ||
MojoGoalExecutionHandler previousHandler = | ||
mojoGoalExecutionHandlers.put(goal, handler); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops - yeah didn't think enough about it, stream doesn't seem good for this case
@ipleten I see on jenkinsci/opentelemetry-plugin#281 that you have CI pipelines build Java applications and packaging them as Docker images. Could you please by any chance:
|
# Conflicts: # maven-extension/src/main/java/io/opentelemetry/maven/OtelExecutionListener.java
3d82fd6
to
81aaeb1
Compare
Description:
Capture details on mojo goal executions:
deploy:deploy
,spring-boot:build-image
,jib:build
,snyk:test
, andsnyk:monitor
Existing Issue(s):
None
Testing:
Introduced unit tests.
Documentation:
See the updated README.md
Outstanding items:
Span Attributes introduced in this PR
Span attributes introduced in this PR.
Key namespaces:
maven.*
: anything related to Mavenmaven.build.*
: anything related to the artifacts produced by Maven buildsmaven.build.container
: producing docker/container imagesmaven.build.container.image.*
: anything related to container images produced by Maven buildsmaven.build.container.registry.*
: attributes to describe container registry to which produced docker images are uploaded., describe theurl
of the registry and theusername
used for authentication.maven.build.repository
: uploading artifacts to a Maven repositorymaven.execution.*
: anything related to the Maven execution (e.g. the goal)maven.plugin.*
: anything related to the Maven plugin that is being executedmaven.project.*
: anything related to the project/module that is buildingNoteworthy: we capture the username used to upload to container registries and Maven repositories to help troubleshooting
maven.build.container.image.name
maven.build.container.image.tags
maven.build.container.registry.auth.username
maven.build.container.registry.url
maven.build.repository.auth.username
maven.build.repository.id
maven.build.repository.url
maven.execution.goal
maven.execution.id
maven.execution.lifecyclePhase
maven.plugin.artifactId
maven.plugin.groupId
maven.plugin.version
maven.project.artifactId
maven.project.groupId
maven.project.version