-
-
Notifications
You must be signed in to change notification settings - Fork 24
fix(tracing): harden span export and telemetry semantics #913
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
Show all changes
8 commits
Select commit
Hold shift + click to select a range
addbd53
fix(tracing): harden span export and telemetry semantics
babs a3e7727
fix(tracing): address review feedback on races and build_id edge
babs 9aa6795
test(tracing): tests and deferred original changes
babs 120a8e8
run unit and golden tests under -race, drop two tests that cannot fail
mzihlmann 671f952
drop excess comments
mzihlmann 85d998a
restore the cmdTimer note, trim the rest of the tracing comments
mzihlmann f5e51ab
move the omit-dockerfile and attribute-cap details to telemetry.md
mzihlmann c032023
guard the tracing globals in Init, restore two doc qualifiers
mzihlmann 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
Some comments aren't visible on the classic Files Changed page.
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| /* | ||
| Copyright 2026 OSS Container Tools | ||
|
|
||
| Licensed under the Apache License, Version 2.0 (the "License"); | ||
| you may not use this file except in compliance with the License. | ||
| You may obtain a copy of the License at | ||
|
|
||
| http://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| Unless required by applicable law or agreed to in writing, software | ||
| distributed under the License is distributed on an "AS IS" BASIS, | ||
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| See the License for the specific language governing permissions and | ||
| limitations under the License. | ||
| */ | ||
|
|
||
| package tracing | ||
|
|
||
| import ( | ||
| "testing" | ||
|
|
||
| "github.com/osscontainertools/kaniko/pkg/config" | ||
| ) | ||
|
|
||
| // Pins the attribute-name contract dashboards are built on. | ||
| func TestBuildAttrs(t *testing.T) { | ||
| t.Setenv("FF_KANIKO_TRACING_TEST_FLAG", "true") | ||
| opts := &config.KanikoOptions{DockerfilePath: "/workspace/Dockerfile"} | ||
|
|
||
| got := map[string]string{} | ||
| for _, kv := range buildAttrs(opts, []byte("FROM scratch")) { | ||
| got[string(kv.Key)] = kv.Value.AsString() | ||
| } | ||
|
|
||
| if got["service.name"] != "kaniko" { | ||
| t.Errorf("service.name = %q, want kaniko", got["service.name"]) | ||
| } | ||
| // FF keys must not double the prefix: kaniko.ff.TRACING_TEST_FLAG, | ||
| // not kaniko.ff.FF_KANIKO_TRACING_TEST_FLAG. | ||
| if got["kaniko.ff.TRACING_TEST_FLAG"] != "true" { | ||
| t.Errorf("kaniko.ff.TRACING_TEST_FLAG = %q, want true", got["kaniko.ff.TRACING_TEST_FLAG"]) | ||
| } | ||
| if _, dup := got["kaniko.ff.FF_KANIKO_TRACING_TEST_FLAG"]; dup { | ||
| t.Error("FF key kept its FF_KANIKO_ prefix") | ||
| } | ||
| if got["kaniko.dockerfile"] != "/workspace/Dockerfile" { | ||
| t.Errorf("kaniko.dockerfile = %q", got["kaniko.dockerfile"]) | ||
| } | ||
| if got["kaniko.build_id"] == "" { | ||
| t.Error("kaniko.build_id missing") | ||
| } | ||
| } | ||
|
|
||
| func TestBuildID(t *testing.T) { | ||
| content := []byte("FROM scratch\nRUN true\n") | ||
| // Content-addressed: same content+target => same id, regardless of path. | ||
| if buildID("/a/Dockerfile", "", content) != buildID("/b/Dockerfile", "", content) { | ||
| t.Error("build_id must depend on content, not path, when content is available") | ||
| } | ||
| // Different content => different id. | ||
| if buildID("/a/Dockerfile", "", content) == buildID("/a/Dockerfile", "", []byte("FROM busybox\n")) { | ||
| t.Error("build_id must change with content") | ||
| } | ||
| // Fallback: no content => path-based, distinct from the content id. | ||
| if buildID("/a/Dockerfile", "", nil) == buildID("/a/Dockerfile", "", content) { | ||
| t.Error("path fallback must differ from the content-based id") | ||
| } | ||
| // A readable-but-empty Dockerfile is content-addressed, not path-based. | ||
| if buildID("/a/Dockerfile", "", []byte{}) != buildID("/b/Dockerfile", "", []byte{}) { | ||
| t.Error("empty readable Dockerfile must be content-addressed") | ||
| } | ||
| } |
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.