Skip to content

Commit 35214b6

Browse files
dmathieupellared
andauthored
Use an absolute path when calling bsd kenv (#8113)
Co-authored-by: Robert Pająk <pellared@hotmail.com>
1 parent 290024c commit 35214b6

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
3535
- Return spec-compliant `TraceIdRatioBased` description. This is a breaking behavioral change, but it is necessary to
3636
make the implementation [spec-compliant](https://opentelemetry.io/docs/specs/otel/trace/sdk/#traceidratiobased). (#8027)
3737
- Fix a race condition in `go.opentelemetry.io/otel/sdk/metric` where the lastvalue aggregation could collect the value 0 even when no zero-value measurements were recorded. (#8056)
38+
- `WithHostID` detector in `go.opentelemetry.io/otel/sdk/resource` to use full path for `kenv` command on BSD. (#8113)
3839
- Fix missing `request.GetBody` in `go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp` to correctly handle HTTP2 GOAWAY frame. (#8096)
3940

4041
<!-- Released section -->

sdk/resource/host_id.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,19 +31,19 @@ type hostIDReaderBSD struct {
3131
readFile fileReader
3232
}
3333

34-
// read attempts to read the machine-id from /etc/hostid. If not found it will
35-
// execute `kenv -q smbios.system.uuid`. If neither location yields an id an
36-
// error will be returned.
34+
// read attempts to read the machine-id from /etc/hostid.
35+
// If not found it will execute: /bin/kenv -q smbios.system.uuid.
36+
// If neither location yields an id an error will be returned.
3737
func (r *hostIDReaderBSD) read() (string, error) {
3838
if result, err := r.readFile("/etc/hostid"); err == nil {
3939
return strings.TrimSpace(result), nil
4040
}
4141

42-
if result, err := r.execCommand("kenv", "-q", "smbios.system.uuid"); err == nil {
42+
if result, err := r.execCommand("/bin/kenv", "-q", "smbios.system.uuid"); err == nil {
4343
return strings.TrimSpace(result), nil
4444
}
4545

46-
return "", errors.New("host id not found in: /etc/hostid or kenv")
46+
return "", errors.New("host id not found in: /etc/hostid or /bin/kenv")
4747
}
4848

4949
// hostIDReaderDarwin implements hostIDReader.

0 commit comments

Comments
 (0)