-
Notifications
You must be signed in to change notification settings - Fork 289
/
AzureVmMetadataResponse.cs
89 lines (73 loc) · 2.82 KB
/
AzureVmMetadataResponse.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0
using System.Text.Json.Serialization;
using OpenTelemetry.Trace;
namespace OpenTelemetry.ResourceDetectors.Azure;
internal sealed class AzureVmMetadataResponse
{
[JsonPropertyName("location")]
public string? Location { get; set; }
[JsonPropertyName("name")]
public string? Name { get; set; }
[JsonPropertyName("osType")]
public string? OsType { get; set; }
[JsonPropertyName("resourceGroupName")]
public string? ResourceGroupName { get; set; }
[JsonPropertyName("resourceId")]
public string? ResourceId { get; set; }
[JsonPropertyName("sku")]
public string? Sku { get; set; }
[JsonPropertyName("subscriptionId")]
public string? SubscriptionId { get; set; }
[JsonPropertyName("version")]
public string? Version { get; set; }
[JsonPropertyName("vmId")]
public string? VmId { get; set; }
[JsonPropertyName("vmScaleSetName")]
public string? VmScaleSetName { get; set; }
[JsonPropertyName("vmSize")]
public string? VmSize { get; set; }
internal string GetValueForField(string fieldName)
{
string? amsValue = null;
switch (fieldName)
{
case ResourceSemanticConventions.AttributeCloudPlatform:
amsValue = ResourceAttributeConstants.AzureVmCloudPlatformValue;
break;
case ResourceSemanticConventions.AttributeCloudProvider:
amsValue = ResourceAttributeConstants.AzureCloudProviderValue;
break;
case ResourceSemanticConventions.AttributeCloudRegion:
amsValue = this.Location;
break;
case ResourceSemanticConventions.AttributeCloudResourceId:
amsValue = this.ResourceId;
break;
case ResourceSemanticConventions.AttributeHostId:
case ResourceSemanticConventions.AttributeServiceInstance:
amsValue = this.VmId;
break;
case ResourceSemanticConventions.AttributeHostName:
amsValue = this.Name;
break;
case ResourceSemanticConventions.AttributeHostType:
amsValue = this.VmSize;
break;
case ResourceSemanticConventions.AttributeOsType:
amsValue = this.OsType;
break;
case ResourceSemanticConventions.AttributeOsVersion:
amsValue = this.Version;
break;
case ResourceAttributeConstants.AzureVmScaleSetName:
amsValue = this.VmScaleSetName;
break;
case ResourceAttributeConstants.AzureVmSku:
amsValue = this.Sku;
break;
}
amsValue ??= string.Empty;
return amsValue;
}
}