Skip to content

Commit 13f45b7

Browse files
committed
PR feedback - add only well known architectures
1 parent 87fefce commit 13f45b7

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

src/OpenTelemetry.Resources.Host/HostDetector.cs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -77,22 +77,24 @@ internal HostDetector(
7777
}
7878

7979
#if !NETFRAMEWORK
80-
#pragma warning disable CA1308
81-
// CA1308 wants ToUpper to be used instead of ToLowerInvariant() here
82-
// but that is incorrect as we want ToLower per OTEL spec
83-
public static string MapArchitectureToOtel(Architecture arch)
80+
public static string? MapArchitectureToOtel(Architecture arch)
8481
{
8582
return arch switch
8683
{
84+
Architecture.X86 => "x86",
8785
Architecture.X64 => "x64",
8886
Architecture.Arm => "arm32",
8987
Architecture.Arm64 => "arm64",
9088
Architecture.S390x => "s390x",
89+
Architecture.Armv6 => "arm32",
9190
Architecture.Ppc64le => "ppc64",
92-
_ => arch.ToString().ToLowerInvariant(),
91+
92+
// following architectures do not have a mapping in OTEL spec https://github.com/open-telemetry/semantic-conventions/blob/v1.37.0/docs/resource/host.md
93+
Architecture.Wasm => null,
94+
Architecture.LoongArch64 => null,
95+
_ => null,
9396
};
9497
}
95-
#pragma warning restore CA1308
9698
#endif
9799

98100
/// <summary>
@@ -118,7 +120,10 @@ public Resource Detect()
118120
#if !NETFRAMEWORK
119121
// Add host architecture attribute using OTEL semantic mapping
120122
var arch = MapArchitectureToOtel(RuntimeInformation.ProcessArchitecture);
121-
attributes.Add(new(HostSemanticConventions.AttributeHostArch, arch));
123+
if (arch != null)
124+
{
125+
attributes.Add(new(HostSemanticConventions.AttributeHostArch, arch));
126+
}
122127
#endif
123128

124129
return new Resource(attributes);

0 commit comments

Comments
 (0)