-
Notifications
You must be signed in to change notification settings - Fork 505
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
metrics: add build command duration metric
This adds a build duration metric for the build command with attributes related to the buildx driver, the error type (if any), and which options were used to perform the build from a subset of the options. This also refactors some of the utility methods used by the git tool to determine filepaths into its own separate package so they can be reused in another place. Also adds a test to ensure the resource is initialized correctly and doesn't error. The otel handler logging message is suppressed on buildx invocations so we never see the error if there's a problem with the schema url. It's so easy to mess up the schema url when upgrading OTEL that we need a proper test to make sure we haven't broken the functionality. Signed-off-by: Jonathan A. Sternberg <[email protected]>
- Loading branch information
1 parent
082d5d7
commit a60f069
Showing
16 changed files
with
254 additions
and
87 deletions.
There are no files selected for viewing
This file contains 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 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 was deleted.
Oops, something went wrong.
This file contains 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 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 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,34 @@ | ||
package confutil | ||
|
||
import ( | ||
"crypto/rand" | ||
"encoding/hex" | ||
"os" | ||
"path/filepath" | ||
"sync" | ||
) | ||
|
||
var nodeIdentifierMu sync.Mutex | ||
|
||
func TryNodeIdentifier(configDir string) (out string) { | ||
nodeIdentifierMu.Lock() | ||
defer nodeIdentifierMu.Unlock() | ||
sessionFile := filepath.Join(configDir, ".buildNodeID") | ||
if _, err := os.Lstat(sessionFile); err != nil { | ||
if os.IsNotExist(err) { // create a new file with stored randomness | ||
b := make([]byte, 8) | ||
if _, err := rand.Read(b); err != nil { | ||
return out | ||
} | ||
if err := os.WriteFile(sessionFile, []byte(hex.EncodeToString(b)), 0600); err != nil { | ||
return out | ||
} | ||
} | ||
} | ||
|
||
dt, err := os.ReadFile(sessionFile) | ||
if err == nil { | ||
return string(dt) | ||
} | ||
return | ||
} |
This file contains 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 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.