forked from open-telemetry/opentelemetry-collector-contrib
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[processor/resourcedetection] Add
host.arch
to system detector (ope…
…n-telemetry#22940) **Description:** Add `host.arch` to system detector. It is detected via `runtime.GOARCH`. This way of detecting may be wrong if running under an emulator or binary translator; the only common case I know of this happening in practice is on ARM64 macOS when using Rosetta. There is a way to detect this (see DataDog/gohai/pull/77) but since we provide arm64 builds for macOS, I think this is a non-issue **Link to tracking Issue:** Fixes open-telemetry#22939 **Testing:** Added unit tests. Tested on my Linux AMD64 laptop **Documentation:** Documented new attribute on README
- Loading branch information
Showing
12 changed files
with
142 additions
and
23 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Use this changelog template to create an entry for release notes. | ||
# If your change doesn't affect end users, such as a test fix or a tooling change, | ||
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label. | ||
|
||
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' | ||
change_type: enhancement | ||
|
||
# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver) | ||
component: resourcedetectionprocessor | ||
|
||
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). | ||
note: The system detector now detects the `host.arch` semantic convention | ||
|
||
# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists. | ||
issues: [22939] | ||
|
||
# (Optional) One or more lines of additional information to render under the primary note. | ||
# These lines will be padded with 2 spaces and then inserted directly into the document. | ||
# Use pipe (|) for multiline entries. | ||
subtext: The GOARCH value is used on architectures that are not well-known |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package internal | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
conventions "go.opentelemetry.io/collector/semconv/v1.18.0" | ||
) | ||
|
||
func TestGOOSToOsType(t *testing.T) { | ||
assert.Equal(t, "darwin", GOOSToOSType("darwin")) | ||
assert.Equal(t, "linux", GOOSToOSType("linux")) | ||
assert.Equal(t, "windows", GOOSToOSType("windows")) | ||
assert.Equal(t, "dragonflybsd", GOOSToOSType("dragonfly")) | ||
assert.Equal(t, "z_os", GOOSToOSType("zos")) | ||
} | ||
|
||
func TestGOARCHToHostArch(t *testing.T) { | ||
tests := []struct { | ||
goarch string | ||
hostArch string | ||
}{ | ||
// well-known values that are supported by Go | ||
{goarch: "386", hostArch: conventions.AttributeHostArchX86}, | ||
{goarch: "amd64", hostArch: conventions.AttributeHostArchAMD64}, | ||
{goarch: "arm", hostArch: conventions.AttributeHostArchARM32}, | ||
{goarch: "arm64", hostArch: conventions.AttributeHostArchARM64}, | ||
{goarch: "ppc64", hostArch: conventions.AttributeHostArchPPC64}, | ||
{goarch: "ppc64le", hostArch: conventions.AttributeHostArchPPC64}, | ||
{goarch: "s390x", hostArch: conventions.AttributeHostArchS390x}, | ||
|
||
// not well-known values | ||
{goarch: "mips", hostArch: "mips"}, | ||
{goarch: "mips64", hostArch: "mips64"}, | ||
{goarch: "mips64le", hostArch: "mips64le"}, | ||
{goarch: "mipsle", hostArch: "mipsle"}, | ||
{goarch: "riscv64", hostArch: "riscv64"}, | ||
} | ||
|
||
for _, tt := range tests { | ||
t.Run(tt.goarch, func(t *testing.T) { | ||
assert.Equal(t, tt.hostArch, GOARCHtoHostArch(tt.goarch)) | ||
}) | ||
} | ||
} |
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
4 changes: 4 additions & 0 deletions
4
processor/resourcedetectionprocessor/internal/system/internal/metadata/generated_config.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
2 changes: 2 additions & 0 deletions
2
...sor/resourcedetectionprocessor/internal/system/internal/metadata/generated_config_test.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
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