Skip to content

Commit

Permalink
Replace Network Type string with Const in ResourceMonitoring (#5398)
Browse files Browse the repository at this point in the history
* Replace Network Type string with Const in ResourceMonitoring

* Apply the change to LinuxNetworkMetrics.cs as well

---------

Co-authored-by: Yifan Zhu <yifzhu@microsoft.com>
  • Loading branch information
makazeu and Yifan Zhu authored Sep 3, 2024
1 parent 3131920 commit 45e8ca3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,12 @@ public LinuxNetworkMetrics(IMeterFactory meterFactory, ITcpStateInfoProvider tcp

private IEnumerable<Measurement<long>> GetMeasurements()
{
const string NetworkTypeKey = "network.type";
const string NetworkStateKey = "system.network.state";

// These are covered in https://github.com/open-telemetry/semantic-conventions/blob/main/docs/rpc/rpc-metrics.md#attributes:
KeyValuePair<string, object?> tcpVersionFourTag = new("network.type", "ipv4");
KeyValuePair<string, object?> tcpVersionSixTag = new("network.type", "ipv6");
KeyValuePair<string, object?> tcpVersionFourTag = new(NetworkTypeKey, "ipv4");
KeyValuePair<string, object?> tcpVersionSixTag = new(NetworkTypeKey, "ipv6");

List<Measurement<long>> measurements = new(24);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,12 @@ public WindowsNetworkMetrics(IMeterFactory meterFactory, ITcpStateInfoProvider t

private IEnumerable<Measurement<long>> GetMeasurements()
{
const string NetworkTypeKey = "network.type";
const string NetworkStateKey = "system.network.state";

// These are covered in https://github.com/open-telemetry/semantic-conventions/blob/main/docs/rpc/rpc-metrics.md#attributes:
KeyValuePair<string, object?> tcpVersionFourTag = new("network.type", "ipv4");
KeyValuePair<string, object?> tcpVersionSixTag = new("network.type", "ipv6");
KeyValuePair<string, object?> tcpVersionFourTag = new(NetworkTypeKey, "ipv4");
KeyValuePair<string, object?> tcpVersionSixTag = new(NetworkTypeKey, "ipv6");

List<Measurement<long>> measurements = new(24);

Expand Down

0 comments on commit 45e8ca3

Please sign in to comment.