Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Resources.AWS] Rename AWS detector namespace #1839

Merged
merged 10 commits into from
May 30, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ body:
- OpenTelemetry.Instrumentation.Wcf
- OpenTelemetry.PersistentStorage.Abstractions
- OpenTelemetry.PersistentStorage.FileSystem
- OpenTelemetry.ResourceDetectors.AWS
- OpenTelemetry.ResourceDetectors.Container
- OpenTelemetry.Resources.AWS
- OpenTelemetry.Resources.Azure
- OpenTelemetry.Resources.Gcp
- OpenTelemetry.Resources.Host
Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/feature_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ body:
- OpenTelemetry.Instrumentation.Wcf
- OpenTelemetry.PersistentStorage.Abstractions
- OpenTelemetry.PersistentStorage.FileSystem
- OpenTelemetry.ResourceDetectors.AWS
- OpenTelemetry.ResourceDetectors.Container
- OpenTelemetry.Resources.AWS
- OpenTelemetry.Resources.Azure
- OpenTelemetry.Resources.Gcp
- OpenTelemetry.Resources.Host
Expand Down
12 changes: 6 additions & 6 deletions .github/component_owners.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ components:
- vishweshbankwar
src/OpenTelemetry.PersistentStorage.FileSystem/:
- vishweshbankwar
src/OpenTelemetry.ResourceDetectors.AWS/:
- srprash
- ppittle
src/OpenTelemetry.ResourceDetectors.Container/:
- iskiselev
src/OpenTelemetry.Resources.AWS/:
- srprash
- ppittle
src/OpenTelemetry.Resources.Azure/:
- rajkumar-rangaraj
- vishweshbankwar
Expand Down Expand Up @@ -149,11 +149,11 @@ components:
- codeblanch
test/OpenTelemetry.PersistentStorage.FileSystem.Tests/:
- vishweshbankwar
test/OpenTelemetry.ResourceDetectors.AWS.Tests/:
- srprash
- ppittle
test/OpenTelemetry.ResourceDetectors.Container.Tests/:
- iskiselev
test/OpenTelemetry.Resources.AWS.Tests/:
- srprash
- ppittle
test/OpenTelemetry.Resources.Azure.Tests/:
- rajkumar-rangaraj
- vishweshbankwar
Expand Down
22 changes: 11 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ jobs:
instrumentation-stackexchangeredis: ['*/OpenTelemetry.Instrumentation.StackExchangeRedis*/**', 'examples/redis/**', '!**/*.md']
instrumentation-wcf: ['*/OpenTelemetry.Instrumentation.Wcf*/**', 'examples/wcf/**', '!**/*.md']
persistentstorage: ['*/OpenTelemetry.PersistentStorage*/**', '!**/*.md']
resourcedetectors-aws: ['*/OpenTelemetry.ResourceDetectors.AWS*/**', '!**/*.md']
resourcedetectors-container: ['*/OpenTelemetry.ResourceDetectors.Container*/**', '!**/*.md']
resources-aws: ['*/OpenTelemetry.Resources.AWS*/**', '!**/*.md']
resources-azure: ['*/OpenTelemetry.Resources.Azure*/**', '!**/*.md']
resources-gcp: ['*/OpenTelemetry.Resources.Gcp*/**', '!**/*.md']
resources-host: ['*/OpenTelemetry.Resources.Host*/**', '!**/*.md']
Expand Down Expand Up @@ -398,27 +398,27 @@ jobs:
project-name: OpenTelemetry.PersistentStorage
code-cov-name: PersistentStorage

build-test-resourcedetectors-aws:
build-test-resourcedetectors-container:
needs: detect-changes
if: |
contains(needs.detect-changes.outputs.changes, 'resourcedetectors-aws')
contains(needs.detect-changes.outputs.changes, 'resourcedetectors-container')
|| contains(needs.detect-changes.outputs.changes, 'build')
|| contains(needs.detect-changes.outputs.changes, 'shared')
uses: ./.github/workflows/Component.BuildTest.yml
with:
project-name: Component[OpenTelemetry.ResourceDetectors.AWS]
code-cov-name: ResourceDetectors.AWS
project-name: Component[OpenTelemetry.ResourceDetectors.Container]
code-cov-name: ResourceDetectors.Container

build-test-resourcedetectors-container:
build-test-resources-aws:
needs: detect-changes
if: |
contains(needs.detect-changes.outputs.changes, 'resourcedetectors-container')
contains(needs.detect-changes.outputs.changes, 'resources-aws')
|| contains(needs.detect-changes.outputs.changes, 'build')
|| contains(needs.detect-changes.outputs.changes, 'shared')
uses: ./.github/workflows/Component.BuildTest.yml
with:
project-name: Component[OpenTelemetry.ResourceDetectors.Container]
code-cov-name: ResourceDetectors.Container
project-name: Component[OpenTelemetry.Resources.AWS]
code-cov-name: Resources.AWS

build-test-resources-azure:
needs: detect-changes
Expand Down Expand Up @@ -524,8 +524,8 @@ jobs:
|| contains(needs.detect-changes.outputs.changes, 'instrumentation-runtime')
|| contains(needs.detect-changes.outputs.changes, 'instrumentation-sqlclient')
|| contains(needs.detect-changes.outputs.changes, 'instrumentation-stackexchangeredis')
|| contains(needs.detect-changes.outputs.changes, 'resourcedetectors-aws')
|| contains(needs.detect-changes.outputs.changes, 'resourcedetectors-container')
|| contains(needs.detect-changes.outputs.changes, 'resources-aws')
|| contains(needs.detect-changes.outputs.changes, 'resources-azure')
|| contains(needs.detect-changes.outputs.changes, 'resources-host')
|| contains(needs.detect-changes.outputs.changes, 'resources-process')
Expand Down Expand Up @@ -572,8 +572,8 @@ jobs:
build-test-instrumentation-stackexchangeredis-integration,
build-test-instrumentation-wcf,
build-test-persistentstorage,
build-test-resourcedetectors-aws,
build-test-resourcedetectors-container,
build-test-resources-aws,
build-test-resources-azure,
build-test-resources-gcp,
build-test-resources-host,
Expand Down
4 changes: 2 additions & 2 deletions opentelemetry-dotnet-contrib.sln
Original file line number Diff line number Diff line change
Expand Up @@ -258,9 +258,9 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Shared", "Shared", "{1FCC8E
src\Shared\UriHelper.cs = src\Shared\UriHelper.cs
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenTelemetry.ResourceDetectors.AWS", "src\OpenTelemetry.ResourceDetectors.AWS\OpenTelemetry.ResourceDetectors.AWS.csproj", "{71BABAC0-E299-48BF-93E2-C11C3840B037}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenTelemetry.Resources.AWS", "src\OpenTelemetry.Resources.AWS\OpenTelemetry.Resources.AWS.csproj", "{71BABAC0-E299-48BF-93E2-C11C3840B037}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenTelemetry.ResourceDetectors.AWS.Tests", "test\OpenTelemetry.ResourceDetectors.AWS.Tests\OpenTelemetry.ResourceDetectors.AWS.Tests.csproj", "{DE898A1E-920E-476F-B0DB-A98AFD6E3BF4}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenTelemetry.Resources.AWS.Tests", "test\OpenTelemetry.Resources.AWS.Tests\OpenTelemetry.Resources.AWS.Tests.csproj", "{DE898A1E-920E-476F-B0DB-A98AFD6E3BF4}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenTelemetry.Exporter.InfluxDB", "src\OpenTelemetry.Exporter.InfluxDB\OpenTelemetry.Exporter.InfluxDB.csproj", "{FD5E9AC8-DC05-4C64-BDC6-D26F5552808E}"
EndProject
Expand Down

This file was deleted.

This file was deleted.

10 changes: 0 additions & 10 deletions src/OpenTelemetry.ResourceDetectors.AWS/AssemblyInfo.cs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
OpenTelemetry.Resources.AWSResourceBuilderExtensions
static OpenTelemetry.Resources.AWSResourceBuilderExtensions.AddAWSEBSDetector(this OpenTelemetry.Resources.ResourceBuilder! builder) -> OpenTelemetry.Resources.ResourceBuilder!
static OpenTelemetry.Resources.AWSResourceBuilderExtensions.AddAWSEC2Detector(this OpenTelemetry.Resources.ResourceBuilder! builder) -> OpenTelemetry.Resources.ResourceBuilder!
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
static OpenTelemetry.Resources.AWSResourceBuilderExtensions.AddAWSECSDetector(this OpenTelemetry.Resources.ResourceBuilder! builder) -> OpenTelemetry.Resources.ResourceBuilder!
static OpenTelemetry.Resources.AWSResourceBuilderExtensions.AddAWSEKSDetector(this OpenTelemetry.Resources.ResourceBuilder! builder) -> OpenTelemetry.Resources.ResourceBuilder!
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,22 @@
#if NET6_0_OR_GREATER
using System.Runtime.InteropServices;
#endif
using OpenTelemetry.ResourceDetectors.AWS.Models;
using OpenTelemetry.Resources;
using OpenTelemetry.Resources.AWS.Models;

namespace OpenTelemetry.ResourceDetectors.AWS;
namespace OpenTelemetry.Resources.AWS;

/// <summary>
/// Resource detector for application running in AWS ElasticBeanstalk environment.
/// Resource detector for application running in AWS Elastic Beanstalk environment.
/// </summary>
public sealed class AWSEBSResourceDetector : IResourceDetector
internal sealed class AWSEBSDetector : IResourceDetector
{
private const string AWSEBSMetadataWindowsFilePath = "C:\\Program Files\\Amazon\\XRay\\environment.conf";
#if NET6_0_OR_GREATER
private const string AWSEBSMetadataLinuxFilePath = "/var/elasticbeanstalk/xray/environment.conf";
#endif

/// <summary>
/// Detector the required and optional resource attributes from AWS ElasticBeanstalk.
/// Detector the required and optional resource attributes from AWS Elastic Beanstalk.
/// </summary>
/// <returns>Resource with key-value pairs of resource attributes.</returns>
public Resource Detect()
Expand All @@ -49,7 +48,7 @@ public Resource Detect()
}
catch (Exception ex)
{
AWSResourcesEventSource.Log.ResourceAttributesExtractException(nameof(AWSEBSResourceDetector), ex);
AWSResourcesEventSource.Log.ResourceAttributesExtractException(nameof(AWSEBSDetector), ex);
}

return Resource.Empty;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@

using System;
using System.Collections.Generic;
using OpenTelemetry.ResourceDetectors.AWS.Models;
using OpenTelemetry.Resources;
using OpenTelemetry.Resources.AWS.Models;

namespace OpenTelemetry.ResourceDetectors.AWS;
namespace OpenTelemetry.Resources.AWS;

/// <summary>
/// Resource detector for application running on AWS EC2 instance.
/// </summary>
public sealed class AWSEC2ResourceDetector : IResourceDetector
internal sealed class AWSEC2Detector : IResourceDetector
{
private const string AWSEC2MetadataTokenTTLHeader = "X-aws-ec2-metadata-token-ttl-seconds";
private const string AWSEC2MetadataTokenHeader = "X-aws-ec2-metadata-token";
Expand All @@ -35,7 +34,7 @@ public Resource Detect()
}
catch (Exception ex)
{
AWSResourcesEventSource.Log.ResourceAttributesExtractException(nameof(AWSEC2ResourceDetector), ex);
AWSResourcesEventSource.Log.ResourceAttributesExtractException(nameof(AWSEC2Detector), ex);
}

return Resource.Empty;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,13 @@
using System.Net.Http;
using System.Text.Json;
using System.Text.RegularExpressions;
using OpenTelemetry.Resources;

namespace OpenTelemetry.ResourceDetectors.AWS;
namespace OpenTelemetry.Resources.AWS;

/// <summary>
/// Resource detector for application running in AWS ECS.
/// </summary>
public sealed class AWSECSResourceDetector : IResourceDetector
internal sealed class AWSECSDetector : IResourceDetector
{
private const string AWSECSMetadataPath = "/proc/self/cgroup";
private const string AWSECSMetadataURLKey = "ECS_CONTAINER_METADATA_URI";
Expand Down Expand Up @@ -47,7 +46,7 @@ public Resource Detect()
}
catch (Exception ex)
{
AWSResourcesEventSource.Log.ResourceAttributesExtractException(nameof(AWSECSResourceDetector), ex);
AWSResourcesEventSource.Log.ResourceAttributesExtractException(nameof(AWSECSDetector), ex);
}

try
Expand All @@ -56,7 +55,7 @@ public Resource Detect()
}
catch (Exception ex)
{
AWSResourcesEventSource.Log.ResourceAttributesExtractException(nameof(AWSECSResourceDetector), ex);
AWSResourcesEventSource.Log.ResourceAttributesExtractException(nameof(AWSECSDetector), ex);
}

return new Resource(resourceAttributes);
Expand All @@ -80,14 +79,14 @@ internal static List<KeyValuePair<string, object>> ExtractMetadataV4ResourceAttr
if (!containerResponse.RootElement.TryGetProperty("ContainerARN", out var containerArnElement)
|| containerArnElement.GetString() is not string containerArn)
{
AWSResourcesEventSource.Log.ResourceAttributesExtractException(nameof(AWSECSResourceDetector), new ArgumentException("The ECS Metadata V4 response did not contain the 'ContainerARN' field"));
AWSResourcesEventSource.Log.ResourceAttributesExtractException(nameof(AWSECSDetector), new ArgumentException("The ECS Metadata V4 response did not contain the 'ContainerARN' field"));
return new List<KeyValuePair<string, object>>();
}

if (!taskResponse.RootElement.TryGetProperty("Cluster", out var clusterArnElement)
|| clusterArnElement.GetString() is not string clusterArn)
{
AWSResourcesEventSource.Log.ResourceAttributesExtractException(nameof(AWSECSResourceDetector), new ArgumentException("The ECS Metadata V4 response did not contain the 'Cluster' field"));
AWSResourcesEventSource.Log.ResourceAttributesExtractException(nameof(AWSECSDetector), new ArgumentException("The ECS Metadata V4 response did not contain the 'Cluster' field"));
return new List<KeyValuePair<string, object>>();
}

Expand Down Expand Up @@ -129,7 +128,7 @@ internal static List<KeyValuePair<string, object>> ExtractMetadataV4ResourceAttr
}
else
{
AWSResourcesEventSource.Log.ResourceAttributesExtractException(nameof(AWSECSResourceDetector), new ArgumentException($"The ECS Metadata V4 response contained the unrecognized launch type '{launchTypeElement}'"));
AWSResourcesEventSource.Log.ResourceAttributesExtractException(nameof(AWSECSDetector), new ArgumentException($"The ECS Metadata V4 response contained the unrecognized launch type '{launchTypeElement}'"));
}

if (taskResponse.RootElement.TryGetProperty("TaskARN", out var taskArnElement) && taskArnElement.ValueKind == JsonValueKind.String)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

#if !NETFRAMEWORK

#if !NETFRAMEWORK
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Text;
using OpenTelemetry.ResourceDetectors.AWS.Models;
using OpenTelemetry.Resources;
using OpenTelemetry.Resources.AWS.Models;

namespace OpenTelemetry.ResourceDetectors.AWS;
namespace OpenTelemetry.Resources.AWS;

/// <summary>
/// Resource detector for application running in AWS EKS.
/// </summary>
public sealed class AWSEKSResourceDetector : IResourceDetector
internal sealed class AWSEKSDetector : IResourceDetector
{
private const string AWSEKSCertificatePath = "/var/run/secrets/kubernetes.io/serviceaccount/ca.crt";
private const string AWSEKSCredentialPath = "/var/run/secrets/kubernetes.io/serviceaccount/token";
Expand Down Expand Up @@ -83,7 +81,7 @@ internal static List<KeyValuePair<string, object>> ExtractResourceAttributes(str
}
catch (Exception ex)
{
AWSResourcesEventSource.Log.ResourceAttributesExtractException($"{nameof(AWSEKSResourceDetector)} : Failed to load client token", ex);
AWSResourcesEventSource.Log.ResourceAttributesExtractException($"{nameof(AWSEKSDetector)} : Failed to load client token", ex);
}

return null;
Expand All @@ -107,7 +105,7 @@ internal static List<KeyValuePair<string, object>> ExtractResourceAttributes(str
}
catch (Exception ex)
{
AWSResourcesEventSource.Log.ResourceAttributesExtractException($"{nameof(AWSEKSResourceDetector)} : Failed to get Container Id", ex);
AWSResourcesEventSource.Log.ResourceAttributesExtractException($"{nameof(AWSEKSDetector)} : Failed to get Container Id", ex);
}

return null;
Expand All @@ -131,7 +129,7 @@ internal static List<KeyValuePair<string, object>> ExtractResourceAttributes(str
}
catch (Exception ex)
{
AWSResourcesEventSource.Log.ResourceAttributesExtractException($"{nameof(AWSEKSResourceDetector)} : Failed to get cluster information", ex);
AWSResourcesEventSource.Log.ResourceAttributesExtractException($"{nameof(AWSEKSDetector)} : Failed to get cluster information", ex);
}

return null;
Expand All @@ -146,7 +144,7 @@ private static bool IsEKSProcess(string credentials, HttpClientHandler? httpClie
}
catch (Exception ex)
{
AWSResourcesEventSource.Log.ResourceAttributesExtractException($"{nameof(AWSEKSResourceDetector)} : Failed to get EKS information", ex);
AWSResourcesEventSource.Log.ResourceAttributesExtractException($"{nameof(AWSEKSDetector)} : Failed to get EKS information", ex);
}

return !string.IsNullOrEmpty(awsAuth);
Expand Down
Loading
Loading