-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
{AzureMonitorDistro] Added Azure Container Apps resource detector. (#…
…41803) * Added Azure Container Apps resource detector. * Update changelog
- Loading branch information
1 parent
c8416d0
commit f250ca2
Showing
9 changed files
with
77 additions
and
87 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
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
55 changes: 55 additions & 0 deletions
55
...src/Vendoring/OpenTelemetry.ResourceDetectors.Azure/AzureContainerAppsResourceDetector.cs
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,55 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using OpenTelemetry.Resources; | ||
using OpenTelemetry.Trace; | ||
|
||
namespace OpenTelemetry.ResourceDetectors.Azure; | ||
|
||
/// <summary> | ||
/// Resource detector for Azure Container Apps environment. | ||
/// </summary> | ||
internal sealed class AzureContainerAppsResourceDetector : IResourceDetector | ||
{ | ||
internal static readonly IReadOnlyDictionary<string, string> AzureContainerResourceAttributes = new Dictionary<string, string> | ||
{ | ||
{ ResourceSemanticConventions.AttributeServiceInstance, ResourceAttributeConstants.AzureContainerAppsReplicaNameEnvVar }, | ||
{ ResourceSemanticConventions.AttributeServiceVersion, ResourceAttributeConstants.AzureContainerAppsRevisionEnvVar }, | ||
}; | ||
|
||
/// <inheritdoc/> | ||
public Resource Detect() | ||
{ | ||
List<KeyValuePair<string, object>> attributeList = new(); | ||
|
||
try | ||
{ | ||
var containerAppName = Environment.GetEnvironmentVariable(ResourceAttributeConstants.AzureContainerAppsNameEnvVar); | ||
|
||
if (containerAppName != null) | ||
{ | ||
attributeList.Add(new KeyValuePair<string, object>(ResourceSemanticConventions.AttributeServiceName, containerAppName)); | ||
attributeList.Add(new KeyValuePair<string, object>(ResourceSemanticConventions.AttributeCloudProvider, ResourceAttributeConstants.AzureCloudProviderValue)); | ||
attributeList.Add(new KeyValuePair<string, object>(ResourceSemanticConventions.AttributeCloudPlatform, ResourceAttributeConstants.AzureContainerAppsPlatformValue)); | ||
|
||
foreach (var kvp in AzureContainerResourceAttributes) | ||
{ | ||
var attributeValue = Environment.GetEnvironmentVariable(kvp.Value); | ||
if (attributeValue != null) | ||
{ | ||
attributeList.Add(new KeyValuePair<string, object>(kvp.Key, attributeValue)); | ||
} | ||
} | ||
} | ||
} | ||
catch | ||
{ | ||
// TODO: log exception. | ||
return Resource.Empty; | ||
} | ||
|
||
return new Resource(attributeList); | ||
} | ||
} |
15 changes: 1 addition & 14 deletions
15
...AspNetCore/src/Vendoring/OpenTelemetry.ResourceDetectors.Azure/AzureVMResourceDetector.cs
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
15 changes: 1 addition & 14 deletions
15
...spNetCore/src/Vendoring/OpenTelemetry.ResourceDetectors.Azure/AzureVmMetaDataRequestor.cs
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
16 changes: 1 addition & 15 deletions
16
...AspNetCore/src/Vendoring/OpenTelemetry.ResourceDetectors.Azure/AzureVmMetadataResponse.cs
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
17 changes: 2 additions & 15 deletions
17
...zure.Monitor.OpenTelemetry.AspNetCore/src/Vendoring/Shared/ResourceSemanticConventions.cs
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