-
Notifications
You must be signed in to change notification settings - Fork 3
feat: standardize Kueue config and restore trace propagation #15
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
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...tor-chart/templates/kueue/localqueue.yaml → ...or-chart/templates/kueue/local-queue.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 0 additions & 9 deletions
9
helm/java-generator-chart/templates/kueue/resourceflavor.yaml
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
src/main/java/org/jboss/sbomer/java/generator/core/utility/TraceUtility.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| package org.jboss.sbomer.java.generator.core.utility; | ||
|
|
||
| import io.opentelemetry.api.trace.Span; | ||
| import io.opentelemetry.api.trace.SpanBuilder; | ||
| import io.opentelemetry.api.trace.SpanContext; | ||
| import io.opentelemetry.api.trace.SpanKind; | ||
| import io.opentelemetry.api.trace.TraceFlags; | ||
| import io.opentelemetry.api.trace.TraceState; | ||
| import io.opentelemetry.api.trace.Tracer; | ||
| import io.opentelemetry.context.Context; | ||
| import lombok.extern.slf4j.Slf4j; | ||
|
|
||
| @Slf4j | ||
| public class TraceUtility { | ||
|
|
||
| private TraceUtility() {} | ||
|
|
||
| /** | ||
| * Returns a SpanBuilder configured as the child of given traceparent. | ||
| * Callers can add their own attributes before calling startSpan(). | ||
| * | ||
| * @param tracer the OTel tracer. | ||
| * @param spanName the span operation name. | ||
| * @param traceParent the W3C traceparent header. | ||
| * @param generationId the generation ID to set as a span attribute. | ||
| * @return a configured {@link SpanBuilder}. | ||
| */ | ||
| public static SpanBuilder childSpanBuilder(Tracer tracer, String spanName, String traceParent, String generationId) { | ||
| SpanBuilder spanBuilder = tracer.spanBuilder(spanName) | ||
| .setSpanKind(SpanKind.INTERNAL) | ||
| .setAttribute("generation.id", generationId != null ? generationId : "unknown"); | ||
| SpanContext parentContext = parseTraceParent(traceParent); | ||
| if (parentContext != null && parentContext.isValid()) { | ||
| spanBuilder.setParent(Context.root().with(Span.wrap(parentContext))); | ||
| } | ||
| return spanBuilder; | ||
| } | ||
|
|
||
| /** | ||
| * Parses W3C traceparent header into SpanContext. | ||
| * Expected format: 00-<traceId>-<spanId>-<traceFlags> | ||
| * | ||
| * @param traceParent the traceparent header value. | ||
| * @return the parsed SpanContext, or null if input is absent or malformed. | ||
| */ | ||
| public static SpanContext parseTraceParent(String traceParent) { | ||
| if (traceParent == null || traceParent.isEmpty()) { | ||
| return null; | ||
| } | ||
| String[] parts = traceParent.split("-"); | ||
| if (parts.length != 4) { | ||
| log.warn("Invalid traceparent header format: {}", traceParent); | ||
| return null; | ||
| } | ||
| try { | ||
| return SpanContext.createFromRemoteParent( | ||
| parts[1], // traceId | ||
| parts[2], // spanId | ||
| TraceFlags.fromHex(parts[3], 0), // traceFlags | ||
| TraceState.getDefault() | ||
| ); | ||
| } catch (Exception e) { | ||
| log.warn("Failed to parse traceparent header '{}': {}", traceParent, e.getMessage()); | ||
| return null; | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Out of curiosity, what is the difference in using Tracer vs using the @WithSpan?
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.
Good question! https://github.com/sbomer-project/sbomer-engineering-hub/blob/main/docs/modules/ROOT/pages/observability-standards.adoc#kubernetes-resource-change
Basically if we just rely on
@WithSpanwe end up with an orphaned TaskReconciler root span because TaskReconciler is triggered by an async Kubernetes event - it has no knowledge of the parent span. It would end up disconnected to the generation request that triggered it and become part of a new trace.