From 4e0d7ac8f6b88d2c310ee64afc0d4cec0f04eb5f Mon Sep 17 00:00:00 2001 From: Matthew Hensley Date: Mon, 22 Apr 2024 16:52:14 -0400 Subject: [PATCH 01/33] initial setup --- opentelemetry-dotnet-contrib.sln | 16 +++++- .../.publicApi/net6.0/PublicAPI.Shipped.txt | 1 + .../.publicApi/net6.0/PublicAPI.Unshipped.txt | 3 + .../netstandard2.0/PublicAPI.Shipped.txt | 1 + .../netstandard2.0/PublicAPI.Unshipped.txt | 3 + .../AssemblyInfo.cs | 10 ++++ .../CHANGELOG.md | 4 ++ .../GCPResourceDetector.cs | 57 +++++++++++++++++++ ...OpenTelemetry.ResourceDetectors.GCP.csproj | 20 +++++++ .../README.md | 14 +++++ .../ResourceAttributeConstants.cs | 14 +++++ .../GlobalUsings.cs | 4 ++ ...lemetry.ResourceDetectors.GCP.Tests.csproj | 25 ++++++++ .../UnitTest1.cs | 13 +++++ 14 files changed, 184 insertions(+), 1 deletion(-) create mode 100644 src/OpenTelemetry.ResourceDetectors.GCP/.publicApi/net6.0/PublicAPI.Shipped.txt create mode 100644 src/OpenTelemetry.ResourceDetectors.GCP/.publicApi/net6.0/PublicAPI.Unshipped.txt create mode 100644 src/OpenTelemetry.ResourceDetectors.GCP/.publicApi/netstandard2.0/PublicAPI.Shipped.txt create mode 100644 src/OpenTelemetry.ResourceDetectors.GCP/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt create mode 100644 src/OpenTelemetry.ResourceDetectors.GCP/AssemblyInfo.cs create mode 100644 src/OpenTelemetry.ResourceDetectors.GCP/CHANGELOG.md create mode 100644 src/OpenTelemetry.ResourceDetectors.GCP/GCPResourceDetector.cs create mode 100644 src/OpenTelemetry.ResourceDetectors.GCP/OpenTelemetry.ResourceDetectors.GCP.csproj create mode 100644 src/OpenTelemetry.ResourceDetectors.GCP/README.md create mode 100644 src/OpenTelemetry.ResourceDetectors.GCP/ResourceAttributeConstants.cs create mode 100644 test/OpenTelemetry.ResourceDetectors.GCP.Tests/GlobalUsings.cs create mode 100644 test/OpenTelemetry.ResourceDetectors.GCP.Tests/OpenTelemetry.ResourceDetectors.GCP.Tests.csproj create mode 100644 test/OpenTelemetry.ResourceDetectors.GCP.Tests/UnitTest1.cs diff --git a/opentelemetry-dotnet-contrib.sln b/opentelemetry-dotnet-contrib.sln index 7f3a0f099b..d4108e1a2d 100644 --- a/opentelemetry-dotnet-contrib.sln +++ b/opentelemetry-dotnet-contrib.sln @@ -341,7 +341,11 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenTelemetry.ResourceDetec EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenTelemetry.ResourceDetectors.Host.Tests", "test\OpenTelemetry.ResourceDetectors.Host.Tests\OpenTelemetry.ResourceDetectors.Host.Tests.csproj", "{36271347-2055-438E-9659-B71542A17A73}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenTelemetry.PersistentStorage.Abstractions.Tests", "test\OpenTelemetry.PersistentStorage.Abstractions.Tests\OpenTelemetry.PersistentStorage.Abstractions.Tests.csproj", "{7AD707F9-DC6D-430A-8834-D5DCD517BF6E}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenTelemetry.PersistentStorage.Abstractions.Tests", "test\OpenTelemetry.PersistentStorage.Abstractions.Tests\OpenTelemetry.PersistentStorage.Abstractions.Tests.csproj", "{7AD707F9-DC6D-430A-8834-D5DCD517BF6E}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenTelemetry.ResourceDetectors.GCP", "src\OpenTelemetry.ResourceDetectors.GCP\OpenTelemetry.ResourceDetectors.GCP.csproj", "{CBC6D677-D1FF-470E-A244-477E8616A245}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenTelemetry.ResourceDetectors.GCP.Tests", "test\OpenTelemetry.ResourceDetectors.GCP.Tests\OpenTelemetry.ResourceDetectors.GCP.Tests.csproj", "{EECE8D5F-C319-42E8-B37C-A41D6FF43E4A}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -689,6 +693,14 @@ Global {7AD707F9-DC6D-430A-8834-D5DCD517BF6E}.Debug|Any CPU.Build.0 = Debug|Any CPU {7AD707F9-DC6D-430A-8834-D5DCD517BF6E}.Release|Any CPU.ActiveCfg = Release|Any CPU {7AD707F9-DC6D-430A-8834-D5DCD517BF6E}.Release|Any CPU.Build.0 = Release|Any CPU + {CBC6D677-D1FF-470E-A244-477E8616A245}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {CBC6D677-D1FF-470E-A244-477E8616A245}.Debug|Any CPU.Build.0 = Debug|Any CPU + {CBC6D677-D1FF-470E-A244-477E8616A245}.Release|Any CPU.ActiveCfg = Release|Any CPU + {CBC6D677-D1FF-470E-A244-477E8616A245}.Release|Any CPU.Build.0 = Release|Any CPU + {EECE8D5F-C319-42E8-B37C-A41D6FF43E4A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {EECE8D5F-C319-42E8-B37C-A41D6FF43E4A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {EECE8D5F-C319-42E8-B37C-A41D6FF43E4A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {EECE8D5F-C319-42E8-B37C-A41D6FF43E4A}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -792,6 +804,8 @@ Global {033CA8D4-1529-413A-B244-07958D5F9A48} = {22DF5DC0-1290-4E83-A9D8-6BB7DE3B3E63} {36271347-2055-438E-9659-B71542A17A73} = {2097345F-4DD3-477D-BC54-A922F9B2B402} {7AD707F9-DC6D-430A-8834-D5DCD517BF6E} = {2097345F-4DD3-477D-BC54-A922F9B2B402} + {CBC6D677-D1FF-470E-A244-477E8616A245} = {22DF5DC0-1290-4E83-A9D8-6BB7DE3B3E63} + {EECE8D5F-C319-42E8-B37C-A41D6FF43E4A} = {2097345F-4DD3-477D-BC54-A922F9B2B402} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {B0816796-CDB3-47D7-8C3C-946434DE3B66} diff --git a/src/OpenTelemetry.ResourceDetectors.GCP/.publicApi/net6.0/PublicAPI.Shipped.txt b/src/OpenTelemetry.ResourceDetectors.GCP/.publicApi/net6.0/PublicAPI.Shipped.txt new file mode 100644 index 0000000000..7dc5c58110 --- /dev/null +++ b/src/OpenTelemetry.ResourceDetectors.GCP/.publicApi/net6.0/PublicAPI.Shipped.txt @@ -0,0 +1 @@ +#nullable enable diff --git a/src/OpenTelemetry.ResourceDetectors.GCP/.publicApi/net6.0/PublicAPI.Unshipped.txt b/src/OpenTelemetry.ResourceDetectors.GCP/.publicApi/net6.0/PublicAPI.Unshipped.txt new file mode 100644 index 0000000000..fc7bd92b24 --- /dev/null +++ b/src/OpenTelemetry.ResourceDetectors.GCP/.publicApi/net6.0/PublicAPI.Unshipped.txt @@ -0,0 +1,3 @@ +OpenTelemetry.ResourceDetectors.GCP.GCPResourceDetector +OpenTelemetry.ResourceDetectors.GCP.GCPResourceDetector.GCPResourceDetector() -> void +OpenTelemetry.ResourceDetectors.GCP.GCPResourceDetector.Detect() -> OpenTelemetry.Resources.Resource! diff --git a/src/OpenTelemetry.ResourceDetectors.GCP/.publicApi/netstandard2.0/PublicAPI.Shipped.txt b/src/OpenTelemetry.ResourceDetectors.GCP/.publicApi/netstandard2.0/PublicAPI.Shipped.txt new file mode 100644 index 0000000000..7dc5c58110 --- /dev/null +++ b/src/OpenTelemetry.ResourceDetectors.GCP/.publicApi/netstandard2.0/PublicAPI.Shipped.txt @@ -0,0 +1 @@ +#nullable enable diff --git a/src/OpenTelemetry.ResourceDetectors.GCP/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt b/src/OpenTelemetry.ResourceDetectors.GCP/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt new file mode 100644 index 0000000000..fc7bd92b24 --- /dev/null +++ b/src/OpenTelemetry.ResourceDetectors.GCP/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt @@ -0,0 +1,3 @@ +OpenTelemetry.ResourceDetectors.GCP.GCPResourceDetector +OpenTelemetry.ResourceDetectors.GCP.GCPResourceDetector.GCPResourceDetector() -> void +OpenTelemetry.ResourceDetectors.GCP.GCPResourceDetector.Detect() -> OpenTelemetry.Resources.Resource! diff --git a/src/OpenTelemetry.ResourceDetectors.GCP/AssemblyInfo.cs b/src/OpenTelemetry.ResourceDetectors.GCP/AssemblyInfo.cs new file mode 100644 index 0000000000..a1790cff80 --- /dev/null +++ b/src/OpenTelemetry.ResourceDetectors.GCP/AssemblyInfo.cs @@ -0,0 +1,10 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +using System.Runtime.CompilerServices; + +#if SIGNED +[assembly: InternalsVisibleTo("OpenTelemetry.ResourceDetectors.GCP.Tests, PublicKey=002400000480000094000000060200000024000052534131000400000100010051c1562a090fb0c9f391012a32198b5e5d9a60e9b80fa2d7b434c9e5ccb7259bd606e66f9660676afc6692b8cdc6793d190904551d2103b7b22fa636dcbb8208839785ba402ea08fc00c8f1500ccef28bbf599aa64ffb1e1d5dc1bf3420a3777badfe697856e9d52070a50c3ea5821c80bef17ca3acffa28f89dd413f096f898")] +#else +[assembly: InternalsVisibleTo("OpenTelemetry.ResourceDetectors.GCP.Tests")] +#endif diff --git a/src/OpenTelemetry.ResourceDetectors.GCP/CHANGELOG.md b/src/OpenTelemetry.ResourceDetectors.GCP/CHANGELOG.md new file mode 100644 index 0000000000..617d979ab2 --- /dev/null +++ b/src/OpenTelemetry.ResourceDetectors.GCP/CHANGELOG.md @@ -0,0 +1,4 @@ +# Changelog + +## Unreleased + diff --git a/src/OpenTelemetry.ResourceDetectors.GCP/GCPResourceDetector.cs b/src/OpenTelemetry.ResourceDetectors.GCP/GCPResourceDetector.cs new file mode 100644 index 0000000000..285996a010 --- /dev/null +++ b/src/OpenTelemetry.ResourceDetectors.GCP/GCPResourceDetector.cs @@ -0,0 +1,57 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +using System.Collections.Generic; +using Google.Api.Gax; +using OpenTelemetry.Resources; +using OpenTelemetry.Trace; + +namespace OpenTelemetry.ResourceDetectors.GCP; + +/// +/// Resource detector for Google Cloud Platform (GCP). +/// +public sealed class GCPResourceDetector : IResourceDetector +{ + /// + public Resource Detect() + { + var platform = Platform.Instance(); + + if (platform == null || platform.ProjectId == null) + { + return Resource.Empty; + } + + List> attributeList = new() + { + new(ResourceSemanticConventions.AttributeCloudProvider, ResourceAttributeConstants.GcpCloudProviderValue), + new(ResourceSemanticConventions.AttributeCloudAccount, platform.ProjectId), + }; + + switch (platform.Type) + { + case PlatformType.Gke: + attributeList.Add(new(ResourceSemanticConventions.AttributeCloudPlatform, ResourceAttributeConstants.GcpGkePlatformValue)); + attributeList.Add(new(ResourceSemanticConventions.AttributeCloudZone, platform.GkeDetails.Zone)); + attributeList.Add(new(ResourceSemanticConventions.AttributeK8sCluster, platform.GkeDetails.ClusterName)); + attributeList.Add(new(ResourceSemanticConventions.AttributeK8sNamespace, platform.GkeDetails.NamespaceId)); + attributeList.Add(new(ResourceSemanticConventions.AttributeK8sPod, platform.GkeDetails.HostName)); + break; + case PlatformType.CloudRun: + attributeList.Add(new(ResourceSemanticConventions.AttributeCloudPlatform, ResourceAttributeConstants.GcpCloudRunPlatformValue)); + attributeList.Add(new(ResourceSemanticConventions.AttributeCloudZone, platform.CloudRunDetails.Zone)); + break; + case PlatformType.Gae: + attributeList.Add(new(ResourceSemanticConventions.AttributeCloudPlatform, ResourceAttributeConstants.GcpGaePlatformValue)); + break; + case PlatformType.Gce: + default: + attributeList.Add(new(ResourceSemanticConventions.AttributeCloudPlatform, ResourceAttributeConstants.GcpGcePlatformValue)); + attributeList.Add(new(ResourceSemanticConventions.AttributeHostId, platform.GceDetails.InstanceId)); + break; + } + + return new Resource(attributeList); + } +} diff --git a/src/OpenTelemetry.ResourceDetectors.GCP/OpenTelemetry.ResourceDetectors.GCP.csproj b/src/OpenTelemetry.ResourceDetectors.GCP/OpenTelemetry.ResourceDetectors.GCP.csproj new file mode 100644 index 0000000000..3ce1507c0d --- /dev/null +++ b/src/OpenTelemetry.ResourceDetectors.GCP/OpenTelemetry.ResourceDetectors.GCP.csproj @@ -0,0 +1,20 @@ + + + net6.0;netstandard2.0 + OpenTelemetry Resource Detectors for Google Cloud Platform environments + $(PackageTags);ResourceDetector + ResourceDetectors.GCP- + + + + + + + + + + + + + + diff --git a/src/OpenTelemetry.ResourceDetectors.GCP/README.md b/src/OpenTelemetry.ResourceDetectors.GCP/README.md new file mode 100644 index 0000000000..eb2a463032 --- /dev/null +++ b/src/OpenTelemetry.ResourceDetectors.GCP/README.md @@ -0,0 +1,14 @@ +# Resource Detectors for Google Cloud Platform environments + +[![NuGet version badge](https://img.shields.io/nuget/v/OpenTelemetry.ResourceDetectors.GCP)](https://www.nuget.org/packages/OpenTelemetry.ResourceDetectors.GCP) +[![NuGet download count badge](https://img.shields.io/nuget/dt/OpenTelemetry.ResourceDetectors.Azure)](https://www.nuget.org/packages/OpenTelemetry.ResourceDetectors.Azure) + +This package contains [Resource +Detectors](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/resource/sdk.md#detecting-resource-information-from-the-environment) +for applications running in Google Cloud Platform environments. + +## Installation + +```shell +dotnet add package --prerelease OpenTelemetry.ResourceDetectors.GCP +``` diff --git a/src/OpenTelemetry.ResourceDetectors.GCP/ResourceAttributeConstants.cs b/src/OpenTelemetry.ResourceDetectors.GCP/ResourceAttributeConstants.cs new file mode 100644 index 0000000000..b5970815c1 --- /dev/null +++ b/src/OpenTelemetry.ResourceDetectors.GCP/ResourceAttributeConstants.cs @@ -0,0 +1,14 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +namespace OpenTelemetry.ResourceDetectors.GCP; + +internal sealed class ResourceAttributeConstants +{ + // GCP resource attributes constant values + internal const string GcpCloudProviderValue = "gcp"; + internal const string GcpGcePlatformValue = "gcp_compute_engine"; + internal const string GcpGaePlatformValue = "gcp_app_engine"; + internal const string GcpCloudRunPlatformValue = "gcp_cloud_run"; + internal const string GcpGkePlatformValue = "gcp_kubernetes_engine"; +} diff --git a/test/OpenTelemetry.ResourceDetectors.GCP.Tests/GlobalUsings.cs b/test/OpenTelemetry.ResourceDetectors.GCP.Tests/GlobalUsings.cs new file mode 100644 index 0000000000..5e39005fb2 --- /dev/null +++ b/test/OpenTelemetry.ResourceDetectors.GCP.Tests/GlobalUsings.cs @@ -0,0 +1,4 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +global using Xunit; \ No newline at end of file diff --git a/test/OpenTelemetry.ResourceDetectors.GCP.Tests/OpenTelemetry.ResourceDetectors.GCP.Tests.csproj b/test/OpenTelemetry.ResourceDetectors.GCP.Tests/OpenTelemetry.ResourceDetectors.GCP.Tests.csproj new file mode 100644 index 0000000000..9e0c30605a --- /dev/null +++ b/test/OpenTelemetry.ResourceDetectors.GCP.Tests/OpenTelemetry.ResourceDetectors.GCP.Tests.csproj @@ -0,0 +1,25 @@ + + + + net8.0 + enable + enable + + false + true + + + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + + diff --git a/test/OpenTelemetry.ResourceDetectors.GCP.Tests/UnitTest1.cs b/test/OpenTelemetry.ResourceDetectors.GCP.Tests/UnitTest1.cs new file mode 100644 index 0000000000..180642fdf1 --- /dev/null +++ b/test/OpenTelemetry.ResourceDetectors.GCP.Tests/UnitTest1.cs @@ -0,0 +1,13 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +namespace OpenTelemetry.ResourceDetectors.GCP.Tests; + +public class UnitTest1 +{ + [Fact] + public void Test1() + { + // TODO + } +} From 0cbfb1443395161047b0e7288f6902ec30d17f68 Mon Sep 17 00:00:00 2001 From: Matthew Hensley Date: Tue, 23 Apr 2024 17:04:34 -0400 Subject: [PATCH 02/33] extract for testing --- .../GCPResourceDetector.cs | 77 +++++++++++++------ 1 file changed, 55 insertions(+), 22 deletions(-) diff --git a/src/OpenTelemetry.ResourceDetectors.GCP/GCPResourceDetector.cs b/src/OpenTelemetry.ResourceDetectors.GCP/GCPResourceDetector.cs index 285996a010..a5dc23476b 100644 --- a/src/OpenTelemetry.ResourceDetectors.GCP/GCPResourceDetector.cs +++ b/src/OpenTelemetry.ResourceDetectors.GCP/GCPResourceDetector.cs @@ -23,35 +23,68 @@ public Resource Detect() return Resource.Empty; } + var attributeList = platform.Type switch + { + PlatformType.Gke => ExtractGkeResourceAttributes(platform), + PlatformType.CloudRun => ExtractCloudRunResourceAttributes(platform), + PlatformType.Gae => ExtractGaeResourceAttributes(platform), + PlatformType.Gce => ExtractGceResourceAttributes(platform), + _ => ExtractGceResourceAttributes(platform), + }; + + return new Resource(attributeList); + } + + internal static List> ExtractGkeResourceAttributes(Platform platform) + { List> attributeList = new() { new(ResourceSemanticConventions.AttributeCloudProvider, ResourceAttributeConstants.GcpCloudProviderValue), new(ResourceSemanticConventions.AttributeCloudAccount, platform.ProjectId), + new(ResourceSemanticConventions.AttributeCloudPlatform, ResourceAttributeConstants.GcpGkePlatformValue), + new(ResourceSemanticConventions.AttributeCloudZone, platform.GkeDetails.Zone), + new(ResourceSemanticConventions.AttributeK8sCluster, platform.GkeDetails.ClusterName), + new(ResourceSemanticConventions.AttributeK8sNamespace, platform.GkeDetails.NamespaceId), + new(ResourceSemanticConventions.AttributeK8sPod, platform.GkeDetails.HostName), }; - switch (platform.Type) + return attributeList; + } + + internal static List> ExtractCloudRunResourceAttributes(Platform platform) + { + List> attributeList = new() { - case PlatformType.Gke: - attributeList.Add(new(ResourceSemanticConventions.AttributeCloudPlatform, ResourceAttributeConstants.GcpGkePlatformValue)); - attributeList.Add(new(ResourceSemanticConventions.AttributeCloudZone, platform.GkeDetails.Zone)); - attributeList.Add(new(ResourceSemanticConventions.AttributeK8sCluster, platform.GkeDetails.ClusterName)); - attributeList.Add(new(ResourceSemanticConventions.AttributeK8sNamespace, platform.GkeDetails.NamespaceId)); - attributeList.Add(new(ResourceSemanticConventions.AttributeK8sPod, platform.GkeDetails.HostName)); - break; - case PlatformType.CloudRun: - attributeList.Add(new(ResourceSemanticConventions.AttributeCloudPlatform, ResourceAttributeConstants.GcpCloudRunPlatformValue)); - attributeList.Add(new(ResourceSemanticConventions.AttributeCloudZone, platform.CloudRunDetails.Zone)); - break; - case PlatformType.Gae: - attributeList.Add(new(ResourceSemanticConventions.AttributeCloudPlatform, ResourceAttributeConstants.GcpGaePlatformValue)); - break; - case PlatformType.Gce: - default: - attributeList.Add(new(ResourceSemanticConventions.AttributeCloudPlatform, ResourceAttributeConstants.GcpGcePlatformValue)); - attributeList.Add(new(ResourceSemanticConventions.AttributeHostId, platform.GceDetails.InstanceId)); - break; - } + new(ResourceSemanticConventions.AttributeCloudProvider, ResourceAttributeConstants.GcpCloudProviderValue), + new(ResourceSemanticConventions.AttributeCloudAccount, platform.ProjectId), + new(ResourceSemanticConventions.AttributeCloudPlatform, ResourceAttributeConstants.GcpCloudRunPlatformValue), + new(ResourceSemanticConventions.AttributeCloudZone, platform.CloudRunDetails.Zone), + }; - return new Resource(attributeList); + return attributeList; + } + + internal static List> ExtractGaeResourceAttributes(Platform platform) + { + List> attributeList = new() + { + new(ResourceSemanticConventions.AttributeCloudProvider, ResourceAttributeConstants.GcpCloudProviderValue), + new(ResourceSemanticConventions.AttributeCloudAccount, platform.ProjectId), + new(ResourceSemanticConventions.AttributeCloudPlatform, ResourceAttributeConstants.GcpGaePlatformValue), + }; + return attributeList; + } + + internal static List> ExtractGceResourceAttributes(Platform platform) +{ + List> attributeList = new() + { + new(ResourceSemanticConventions.AttributeCloudProvider, ResourceAttributeConstants.GcpCloudProviderValue), + new(ResourceSemanticConventions.AttributeCloudAccount, platform.ProjectId), + new(ResourceSemanticConventions.AttributeCloudPlatform, ResourceAttributeConstants.GcpGcePlatformValue), + new(ResourceSemanticConventions.AttributeHostId, platform.GceDetails.InstanceId), + }; + + return attributeList; } } From 40599ade91060f84c87fa375016221dfed3444b2 Mon Sep 17 00:00:00 2001 From: Matthew Hensley Date: Wed, 24 Apr 2024 13:40:48 -0400 Subject: [PATCH 03/33] resource attr extraction tests --- .../GCPResourceDetectorTests.cs | 93 +++++++++++++++++++ ...lemetry.ResourceDetectors.GCP.Tests.csproj | 5 + .../UnitTest1.cs | 13 --- 3 files changed, 98 insertions(+), 13 deletions(-) create mode 100644 test/OpenTelemetry.ResourceDetectors.GCP.Tests/GCPResourceDetectorTests.cs delete mode 100644 test/OpenTelemetry.ResourceDetectors.GCP.Tests/UnitTest1.cs diff --git a/test/OpenTelemetry.ResourceDetectors.GCP.Tests/GCPResourceDetectorTests.cs b/test/OpenTelemetry.ResourceDetectors.GCP.Tests/GCPResourceDetectorTests.cs new file mode 100644 index 0000000000..6f30ad20e6 --- /dev/null +++ b/test/OpenTelemetry.ResourceDetectors.GCP.Tests/GCPResourceDetectorTests.cs @@ -0,0 +1,93 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +using Google.Api.Gax; +using OpenTelemetry.Trace; + +namespace OpenTelemetry.ResourceDetectors.GCP.Tests; + +public class GCPResourceDetectorTests +{ + [Fact] + public void TestExtractGkeResourceAttributes() + { + var details = new GkePlatformDetails( + metadataJson: "json", + projectId: "projectId", + clusterName: "clusterName", + location: "location", + hostName: "hostName", + instanceId: "instanceId", + zone: "us-central1-a", + namespaceId: "namespaceId", + podId: "podId", + containerName: "containerName", + clusterLocation: "clusterLocation"); + var platform = new Platform(details); + var attrs = GCPResourceDetector.ExtractGkeResourceAttributes(platform).ToDictionary(x => x.Key, x => x.Value); + Assert.NotNull(attrs); + Assert.Equal(7, attrs.Count); + Assert.Equal(ResourceAttributeConstants.GcpCloudProviderValue, attrs[ResourceSemanticConventions.AttributeCloudProvider]); + Assert.Equal("projectId", attrs[ResourceSemanticConventions.AttributeCloudAccount]); + Assert.Equal(ResourceAttributeConstants.GcpGkePlatformValue, attrs[ResourceSemanticConventions.AttributeCloudPlatform]); + Assert.Equal("us-central1-a", attrs[ResourceSemanticConventions.AttributeCloudZone]); + Assert.Equal("clusterName", attrs[ResourceSemanticConventions.AttributeK8sCluster]); + Assert.Equal("namespaceId", attrs[ResourceSemanticConventions.AttributeK8sNamespace]); + Assert.Equal("hostName", attrs[ResourceSemanticConventions.AttributeK8sPod]); + } + + [Fact] + public void TestExtractCloudRunResourceAttributes() + { + var details = new CloudRunPlatformDetails( + metadataJson: "json", + projectId: "projectId", + zone: "us-central1-a", + serviceName: "serviceName", + revisionName: "revisionName", + configurationName: "configurationName"); + var platform = new Platform(details); + var attrs = GCPResourceDetector.ExtractCloudRunResourceAttributes(platform).ToDictionary(x => x.Key, x => x.Value); + Assert.NotNull(attrs); + Assert.Equal(4, attrs.Count); + Assert.Equal(ResourceAttributeConstants.GcpCloudProviderValue, attrs[ResourceSemanticConventions.AttributeCloudProvider]); + Assert.Equal("projectId", attrs[ResourceSemanticConventions.AttributeCloudAccount]); + Assert.Equal(ResourceAttributeConstants.GcpCloudRunPlatformValue, attrs[ResourceSemanticConventions.AttributeCloudPlatform]); + Assert.Equal("us-central1-a", attrs[ResourceSemanticConventions.AttributeCloudZone]); + } + + [Fact] + public void TestExtractGaeResourceAttributes() + { + var details = new GaePlatformDetails( + gcloudProject: "gcloudProject", + gaeInstance: "gaeInstance", + gaeService: "gaeService", + gaeVersion: "gaeVersion"); + var platform = new Platform(details); + var attrs = GCPResourceDetector.ExtractGaeResourceAttributes(platform).ToDictionary(x => x.Key, x => x.Value); + Assert.NotNull(attrs); + Assert.Equal(3, attrs.Count); + Assert.Equal(ResourceAttributeConstants.GcpCloudProviderValue, attrs[ResourceSemanticConventions.AttributeCloudProvider]); + Assert.Equal("gcloudProject", attrs[ResourceSemanticConventions.AttributeCloudAccount]); + Assert.Equal(ResourceAttributeConstants.GcpGaePlatformValue, attrs[ResourceSemanticConventions.AttributeCloudPlatform]); + } + + [Fact] + public void TestExtractGceResourceAttributes() + { + var details = new GcePlatformDetails( + metadataJson: "json", + projectId: "projectId", + instanceId: "instanceId", + zoneName: "us-central1-a"); + var platform = new Platform(details); + var attrs = GCPResourceDetector.ExtractGceResourceAttributes(platform).ToDictionary(x => x.Key, x => x.Value); + Assert.NotNull(attrs); + Assert.Equal(4, attrs.Count); + Assert.Equal(ResourceAttributeConstants.GcpCloudProviderValue, attrs[ResourceSemanticConventions.AttributeCloudProvider]); + Assert.Equal("projectId", attrs[ResourceSemanticConventions.AttributeCloudAccount]); + Assert.Equal(ResourceAttributeConstants.GcpGcePlatformValue, attrs[ResourceSemanticConventions.AttributeCloudPlatform]); + Assert.Equal("instanceId", attrs[ResourceSemanticConventions.AttributeHostId]); + } +} diff --git a/test/OpenTelemetry.ResourceDetectors.GCP.Tests/OpenTelemetry.ResourceDetectors.GCP.Tests.csproj b/test/OpenTelemetry.ResourceDetectors.GCP.Tests/OpenTelemetry.ResourceDetectors.GCP.Tests.csproj index 9e0c30605a..772bbfb3d3 100644 --- a/test/OpenTelemetry.ResourceDetectors.GCP.Tests/OpenTelemetry.ResourceDetectors.GCP.Tests.csproj +++ b/test/OpenTelemetry.ResourceDetectors.GCP.Tests/OpenTelemetry.ResourceDetectors.GCP.Tests.csproj @@ -10,6 +10,7 @@ + @@ -22,4 +23,8 @@ + + + + diff --git a/test/OpenTelemetry.ResourceDetectors.GCP.Tests/UnitTest1.cs b/test/OpenTelemetry.ResourceDetectors.GCP.Tests/UnitTest1.cs deleted file mode 100644 index 180642fdf1..0000000000 --- a/test/OpenTelemetry.ResourceDetectors.GCP.Tests/UnitTest1.cs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -namespace OpenTelemetry.ResourceDetectors.GCP.Tests; - -public class UnitTest1 -{ - [Fact] - public void Test1() - { - // TODO - } -} From fe9a3e82d51bfec8648879ba54ce671579e2be4f Mon Sep 17 00:00:00 2001 From: Matthew Hensley Date: Wed, 24 Apr 2024 13:48:40 -0400 Subject: [PATCH 04/33] align with other test projects --- .../GCPResourceDetectorTests.cs | 1 + .../GlobalUsings.cs | 2 +- ...lemetry.ResourceDetectors.GCP.Tests.csproj | 22 +++++-------------- 3 files changed, 7 insertions(+), 18 deletions(-) diff --git a/test/OpenTelemetry.ResourceDetectors.GCP.Tests/GCPResourceDetectorTests.cs b/test/OpenTelemetry.ResourceDetectors.GCP.Tests/GCPResourceDetectorTests.cs index 6f30ad20e6..50785845aa 100644 --- a/test/OpenTelemetry.ResourceDetectors.GCP.Tests/GCPResourceDetectorTests.cs +++ b/test/OpenTelemetry.ResourceDetectors.GCP.Tests/GCPResourceDetectorTests.cs @@ -1,6 +1,7 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +using System.Linq; using Google.Api.Gax; using OpenTelemetry.Trace; diff --git a/test/OpenTelemetry.ResourceDetectors.GCP.Tests/GlobalUsings.cs b/test/OpenTelemetry.ResourceDetectors.GCP.Tests/GlobalUsings.cs index 5e39005fb2..c9112be5f0 100644 --- a/test/OpenTelemetry.ResourceDetectors.GCP.Tests/GlobalUsings.cs +++ b/test/OpenTelemetry.ResourceDetectors.GCP.Tests/GlobalUsings.cs @@ -1,4 +1,4 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -global using Xunit; \ No newline at end of file +global using Xunit; diff --git a/test/OpenTelemetry.ResourceDetectors.GCP.Tests/OpenTelemetry.ResourceDetectors.GCP.Tests.csproj b/test/OpenTelemetry.ResourceDetectors.GCP.Tests/OpenTelemetry.ResourceDetectors.GCP.Tests.csproj index 772bbfb3d3..251f1668b1 100644 --- a/test/OpenTelemetry.ResourceDetectors.GCP.Tests/OpenTelemetry.ResourceDetectors.GCP.Tests.csproj +++ b/test/OpenTelemetry.ResourceDetectors.GCP.Tests/OpenTelemetry.ResourceDetectors.GCP.Tests.csproj @@ -1,30 +1,18 @@ - net8.0 - enable - enable - - false - true + Unit test project for GCP Detector for OpenTelemetry + + $(SupportedNetTargets) + $(TargetFrameworks);$(NetFrameworkMinimumSupportedVersion) - - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - + From 74988077e62d947d4f7749c58296671adc25cbdf Mon Sep 17 00:00:00 2001 From: Matthew Hensley Date: Wed, 24 Apr 2024 13:58:17 -0400 Subject: [PATCH 05/33] follow naming convention --- opentelemetry-dotnet-contrib.sln | 4 ++-- .../.publicApi/net6.0/PublicAPI.Unshipped.txt | 3 --- .../netstandard2.0/PublicAPI.Unshipped.txt | 3 --- .../.publicApi/net6.0/PublicAPI.Shipped.txt | 0 .../.publicApi/net6.0/PublicAPI.Unshipped.txt | 3 +++ .../.publicApi/netstandard2.0/PublicAPI.Shipped.txt | 0 .../netstandard2.0/PublicAPI.Unshipped.txt | 3 +++ .../AssemblyInfo.cs | 4 ++-- .../CHANGELOG.md | 0 .../GcpResourceDetector.cs} | 4 ++-- .../OpenTelemetry.ResourceDetectors.Gcp.csproj} | 0 .../README.md | 0 .../ResourceAttributeConstants.cs | 2 +- .../GcpResourceDetectorTests.cs} | 12 ++++++------ .../GlobalUsings.cs | 0 ...OpenTelemetry.ResourceDetectors.Gcp.Tests.csproj} | 2 +- 16 files changed, 20 insertions(+), 20 deletions(-) delete mode 100644 src/OpenTelemetry.ResourceDetectors.GCP/.publicApi/net6.0/PublicAPI.Unshipped.txt delete mode 100644 src/OpenTelemetry.ResourceDetectors.GCP/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt rename src/{OpenTelemetry.ResourceDetectors.GCP => OpenTelemetry.ResourceDetectors.Gcp}/.publicApi/net6.0/PublicAPI.Shipped.txt (100%) create mode 100644 src/OpenTelemetry.ResourceDetectors.Gcp/.publicApi/net6.0/PublicAPI.Unshipped.txt rename src/{OpenTelemetry.ResourceDetectors.GCP => OpenTelemetry.ResourceDetectors.Gcp}/.publicApi/netstandard2.0/PublicAPI.Shipped.txt (100%) create mode 100644 src/OpenTelemetry.ResourceDetectors.Gcp/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt rename src/{OpenTelemetry.ResourceDetectors.GCP => OpenTelemetry.ResourceDetectors.Gcp}/AssemblyInfo.cs (87%) rename src/{OpenTelemetry.ResourceDetectors.GCP => OpenTelemetry.ResourceDetectors.Gcp}/CHANGELOG.md (100%) rename src/{OpenTelemetry.ResourceDetectors.GCP/GCPResourceDetector.cs => OpenTelemetry.ResourceDetectors.Gcp/GcpResourceDetector.cs} (97%) rename src/{OpenTelemetry.ResourceDetectors.GCP/OpenTelemetry.ResourceDetectors.GCP.csproj => OpenTelemetry.ResourceDetectors.Gcp/OpenTelemetry.ResourceDetectors.Gcp.csproj} (100%) rename src/{OpenTelemetry.ResourceDetectors.GCP => OpenTelemetry.ResourceDetectors.Gcp}/README.md (100%) rename src/{OpenTelemetry.ResourceDetectors.GCP => OpenTelemetry.ResourceDetectors.Gcp}/ResourceAttributeConstants.cs (91%) rename test/{OpenTelemetry.ResourceDetectors.GCP.Tests/GCPResourceDetectorTests.cs => OpenTelemetry.ResourceDetectors.Gcp.Tests/GcpResourceDetectorTests.cs} (92%) rename test/{OpenTelemetry.ResourceDetectors.GCP.Tests => OpenTelemetry.ResourceDetectors.Gcp.Tests}/GlobalUsings.cs (100%) rename test/{OpenTelemetry.ResourceDetectors.GCP.Tests/OpenTelemetry.ResourceDetectors.GCP.Tests.csproj => OpenTelemetry.ResourceDetectors.Gcp.Tests/OpenTelemetry.ResourceDetectors.Gcp.Tests.csproj} (91%) diff --git a/opentelemetry-dotnet-contrib.sln b/opentelemetry-dotnet-contrib.sln index 0077caeb53..66014ef85a 100644 --- a/opentelemetry-dotnet-contrib.sln +++ b/opentelemetry-dotnet-contrib.sln @@ -347,9 +347,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenTelemetry.ResourceDetec EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenTelemetry.PersistentStorage.Abstractions.Tests", "test\OpenTelemetry.PersistentStorage.Abstractions.Tests\OpenTelemetry.PersistentStorage.Abstractions.Tests.csproj", "{7AD707F9-DC6D-430A-8834-D5DCD517BF6E}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenTelemetry.ResourceDetectors.GCP", "src\OpenTelemetry.ResourceDetectors.GCP\OpenTelemetry.ResourceDetectors.GCP.csproj", "{CBC6D677-D1FF-470E-A244-477E8616A245}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenTelemetry.ResourceDetectors.Gcp", "src\OpenTelemetry.ResourceDetectors.Gcp\OpenTelemetry.ResourceDetectors.Gcp.csproj", "{CBC6D677-D1FF-470E-A244-477E8616A245}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenTelemetry.ResourceDetectors.GCP.Tests", "test\OpenTelemetry.ResourceDetectors.GCP.Tests\OpenTelemetry.ResourceDetectors.GCP.Tests.csproj", "{EECE8D5F-C319-42E8-B37C-A41D6FF43E4A}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenTelemetry.ResourceDetectors.Gcp.Tests", "test\OpenTelemetry.ResourceDetectors.Gcp.Tests\OpenTelemetry.ResourceDetectors.Gcp.Tests.csproj", "{EECE8D5F-C319-42E8-B37C-A41D6FF43E4A}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/src/OpenTelemetry.ResourceDetectors.GCP/.publicApi/net6.0/PublicAPI.Unshipped.txt b/src/OpenTelemetry.ResourceDetectors.GCP/.publicApi/net6.0/PublicAPI.Unshipped.txt deleted file mode 100644 index fc7bd92b24..0000000000 --- a/src/OpenTelemetry.ResourceDetectors.GCP/.publicApi/net6.0/PublicAPI.Unshipped.txt +++ /dev/null @@ -1,3 +0,0 @@ -OpenTelemetry.ResourceDetectors.GCP.GCPResourceDetector -OpenTelemetry.ResourceDetectors.GCP.GCPResourceDetector.GCPResourceDetector() -> void -OpenTelemetry.ResourceDetectors.GCP.GCPResourceDetector.Detect() -> OpenTelemetry.Resources.Resource! diff --git a/src/OpenTelemetry.ResourceDetectors.GCP/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt b/src/OpenTelemetry.ResourceDetectors.GCP/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt deleted file mode 100644 index fc7bd92b24..0000000000 --- a/src/OpenTelemetry.ResourceDetectors.GCP/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt +++ /dev/null @@ -1,3 +0,0 @@ -OpenTelemetry.ResourceDetectors.GCP.GCPResourceDetector -OpenTelemetry.ResourceDetectors.GCP.GCPResourceDetector.GCPResourceDetector() -> void -OpenTelemetry.ResourceDetectors.GCP.GCPResourceDetector.Detect() -> OpenTelemetry.Resources.Resource! diff --git a/src/OpenTelemetry.ResourceDetectors.GCP/.publicApi/net6.0/PublicAPI.Shipped.txt b/src/OpenTelemetry.ResourceDetectors.Gcp/.publicApi/net6.0/PublicAPI.Shipped.txt similarity index 100% rename from src/OpenTelemetry.ResourceDetectors.GCP/.publicApi/net6.0/PublicAPI.Shipped.txt rename to src/OpenTelemetry.ResourceDetectors.Gcp/.publicApi/net6.0/PublicAPI.Shipped.txt diff --git a/src/OpenTelemetry.ResourceDetectors.Gcp/.publicApi/net6.0/PublicAPI.Unshipped.txt b/src/OpenTelemetry.ResourceDetectors.Gcp/.publicApi/net6.0/PublicAPI.Unshipped.txt new file mode 100644 index 0000000000..45c069df18 --- /dev/null +++ b/src/OpenTelemetry.ResourceDetectors.Gcp/.publicApi/net6.0/PublicAPI.Unshipped.txt @@ -0,0 +1,3 @@ +OpenTelemetry.ResourceDetectors.Gcp.GcpResourceDetector +OpenTelemetry.ResourceDetectors.Gcp.GcpResourceDetector.GcpResourceDetector() -> void +OpenTelemetry.ResourceDetectors.Gcp.GcpResourceDetector.Detect() -> OpenTelemetry.Resources.Resource! diff --git a/src/OpenTelemetry.ResourceDetectors.GCP/.publicApi/netstandard2.0/PublicAPI.Shipped.txt b/src/OpenTelemetry.ResourceDetectors.Gcp/.publicApi/netstandard2.0/PublicAPI.Shipped.txt similarity index 100% rename from src/OpenTelemetry.ResourceDetectors.GCP/.publicApi/netstandard2.0/PublicAPI.Shipped.txt rename to src/OpenTelemetry.ResourceDetectors.Gcp/.publicApi/netstandard2.0/PublicAPI.Shipped.txt diff --git a/src/OpenTelemetry.ResourceDetectors.Gcp/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt b/src/OpenTelemetry.ResourceDetectors.Gcp/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt new file mode 100644 index 0000000000..45c069df18 --- /dev/null +++ b/src/OpenTelemetry.ResourceDetectors.Gcp/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt @@ -0,0 +1,3 @@ +OpenTelemetry.ResourceDetectors.Gcp.GcpResourceDetector +OpenTelemetry.ResourceDetectors.Gcp.GcpResourceDetector.GcpResourceDetector() -> void +OpenTelemetry.ResourceDetectors.Gcp.GcpResourceDetector.Detect() -> OpenTelemetry.Resources.Resource! diff --git a/src/OpenTelemetry.ResourceDetectors.GCP/AssemblyInfo.cs b/src/OpenTelemetry.ResourceDetectors.Gcp/AssemblyInfo.cs similarity index 87% rename from src/OpenTelemetry.ResourceDetectors.GCP/AssemblyInfo.cs rename to src/OpenTelemetry.ResourceDetectors.Gcp/AssemblyInfo.cs index a1790cff80..4b2346eec8 100644 --- a/src/OpenTelemetry.ResourceDetectors.GCP/AssemblyInfo.cs +++ b/src/OpenTelemetry.ResourceDetectors.Gcp/AssemblyInfo.cs @@ -4,7 +4,7 @@ using System.Runtime.CompilerServices; #if SIGNED -[assembly: InternalsVisibleTo("OpenTelemetry.ResourceDetectors.GCP.Tests, PublicKey=002400000480000094000000060200000024000052534131000400000100010051c1562a090fb0c9f391012a32198b5e5d9a60e9b80fa2d7b434c9e5ccb7259bd606e66f9660676afc6692b8cdc6793d190904551d2103b7b22fa636dcbb8208839785ba402ea08fc00c8f1500ccef28bbf599aa64ffb1e1d5dc1bf3420a3777badfe697856e9d52070a50c3ea5821c80bef17ca3acffa28f89dd413f096f898")] +[assembly: InternalsVisibleTo("OpenTelemetry.ResourceDetectors.Gcp.Tests, PublicKey=002400000480000094000000060200000024000052534131000400000100010051c1562a090fb0c9f391012a32198b5e5d9a60e9b80fa2d7b434c9e5ccb7259bd606e66f9660676afc6692b8cdc6793d190904551d2103b7b22fa636dcbb8208839785ba402ea08fc00c8f1500ccef28bbf599aa64ffb1e1d5dc1bf3420a3777badfe697856e9d52070a50c3ea5821c80bef17ca3acffa28f89dd413f096f898")] #else -[assembly: InternalsVisibleTo("OpenTelemetry.ResourceDetectors.GCP.Tests")] +[assembly: InternalsVisibleTo("OpenTelemetry.ResourceDetectors.Gcp.Tests")] #endif diff --git a/src/OpenTelemetry.ResourceDetectors.GCP/CHANGELOG.md b/src/OpenTelemetry.ResourceDetectors.Gcp/CHANGELOG.md similarity index 100% rename from src/OpenTelemetry.ResourceDetectors.GCP/CHANGELOG.md rename to src/OpenTelemetry.ResourceDetectors.Gcp/CHANGELOG.md diff --git a/src/OpenTelemetry.ResourceDetectors.GCP/GCPResourceDetector.cs b/src/OpenTelemetry.ResourceDetectors.Gcp/GcpResourceDetector.cs similarity index 97% rename from src/OpenTelemetry.ResourceDetectors.GCP/GCPResourceDetector.cs rename to src/OpenTelemetry.ResourceDetectors.Gcp/GcpResourceDetector.cs index a5dc23476b..dd739e527c 100644 --- a/src/OpenTelemetry.ResourceDetectors.GCP/GCPResourceDetector.cs +++ b/src/OpenTelemetry.ResourceDetectors.Gcp/GcpResourceDetector.cs @@ -6,12 +6,12 @@ using OpenTelemetry.Resources; using OpenTelemetry.Trace; -namespace OpenTelemetry.ResourceDetectors.GCP; +namespace OpenTelemetry.ResourceDetectors.Gcp; /// /// Resource detector for Google Cloud Platform (GCP). /// -public sealed class GCPResourceDetector : IResourceDetector +public sealed class GcpResourceDetector : IResourceDetector { /// public Resource Detect() diff --git a/src/OpenTelemetry.ResourceDetectors.GCP/OpenTelemetry.ResourceDetectors.GCP.csproj b/src/OpenTelemetry.ResourceDetectors.Gcp/OpenTelemetry.ResourceDetectors.Gcp.csproj similarity index 100% rename from src/OpenTelemetry.ResourceDetectors.GCP/OpenTelemetry.ResourceDetectors.GCP.csproj rename to src/OpenTelemetry.ResourceDetectors.Gcp/OpenTelemetry.ResourceDetectors.Gcp.csproj diff --git a/src/OpenTelemetry.ResourceDetectors.GCP/README.md b/src/OpenTelemetry.ResourceDetectors.Gcp/README.md similarity index 100% rename from src/OpenTelemetry.ResourceDetectors.GCP/README.md rename to src/OpenTelemetry.ResourceDetectors.Gcp/README.md diff --git a/src/OpenTelemetry.ResourceDetectors.GCP/ResourceAttributeConstants.cs b/src/OpenTelemetry.ResourceDetectors.Gcp/ResourceAttributeConstants.cs similarity index 91% rename from src/OpenTelemetry.ResourceDetectors.GCP/ResourceAttributeConstants.cs rename to src/OpenTelemetry.ResourceDetectors.Gcp/ResourceAttributeConstants.cs index b5970815c1..00e9f46ec5 100644 --- a/src/OpenTelemetry.ResourceDetectors.GCP/ResourceAttributeConstants.cs +++ b/src/OpenTelemetry.ResourceDetectors.Gcp/ResourceAttributeConstants.cs @@ -1,7 +1,7 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -namespace OpenTelemetry.ResourceDetectors.GCP; +namespace OpenTelemetry.ResourceDetectors.Gcp; internal sealed class ResourceAttributeConstants { diff --git a/test/OpenTelemetry.ResourceDetectors.GCP.Tests/GCPResourceDetectorTests.cs b/test/OpenTelemetry.ResourceDetectors.Gcp.Tests/GcpResourceDetectorTests.cs similarity index 92% rename from test/OpenTelemetry.ResourceDetectors.GCP.Tests/GCPResourceDetectorTests.cs rename to test/OpenTelemetry.ResourceDetectors.Gcp.Tests/GcpResourceDetectorTests.cs index 50785845aa..86264ecdfe 100644 --- a/test/OpenTelemetry.ResourceDetectors.GCP.Tests/GCPResourceDetectorTests.cs +++ b/test/OpenTelemetry.ResourceDetectors.Gcp.Tests/GcpResourceDetectorTests.cs @@ -5,9 +5,9 @@ using Google.Api.Gax; using OpenTelemetry.Trace; -namespace OpenTelemetry.ResourceDetectors.GCP.Tests; +namespace OpenTelemetry.ResourceDetectors.Gcp.Tests; -public class GCPResourceDetectorTests +public class GcpResourceDetectorTests { [Fact] public void TestExtractGkeResourceAttributes() @@ -25,7 +25,7 @@ public void TestExtractGkeResourceAttributes() containerName: "containerName", clusterLocation: "clusterLocation"); var platform = new Platform(details); - var attrs = GCPResourceDetector.ExtractGkeResourceAttributes(platform).ToDictionary(x => x.Key, x => x.Value); + var attrs = GcpResourceDetector.ExtractGkeResourceAttributes(platform).ToDictionary(x => x.Key, x => x.Value); Assert.NotNull(attrs); Assert.Equal(7, attrs.Count); Assert.Equal(ResourceAttributeConstants.GcpCloudProviderValue, attrs[ResourceSemanticConventions.AttributeCloudProvider]); @@ -48,7 +48,7 @@ public void TestExtractCloudRunResourceAttributes() revisionName: "revisionName", configurationName: "configurationName"); var platform = new Platform(details); - var attrs = GCPResourceDetector.ExtractCloudRunResourceAttributes(platform).ToDictionary(x => x.Key, x => x.Value); + var attrs = GcpResourceDetector.ExtractCloudRunResourceAttributes(platform).ToDictionary(x => x.Key, x => x.Value); Assert.NotNull(attrs); Assert.Equal(4, attrs.Count); Assert.Equal(ResourceAttributeConstants.GcpCloudProviderValue, attrs[ResourceSemanticConventions.AttributeCloudProvider]); @@ -66,7 +66,7 @@ public void TestExtractGaeResourceAttributes() gaeService: "gaeService", gaeVersion: "gaeVersion"); var platform = new Platform(details); - var attrs = GCPResourceDetector.ExtractGaeResourceAttributes(platform).ToDictionary(x => x.Key, x => x.Value); + var attrs = GcpResourceDetector.ExtractGaeResourceAttributes(platform).ToDictionary(x => x.Key, x => x.Value); Assert.NotNull(attrs); Assert.Equal(3, attrs.Count); Assert.Equal(ResourceAttributeConstants.GcpCloudProviderValue, attrs[ResourceSemanticConventions.AttributeCloudProvider]); @@ -83,7 +83,7 @@ public void TestExtractGceResourceAttributes() instanceId: "instanceId", zoneName: "us-central1-a"); var platform = new Platform(details); - var attrs = GCPResourceDetector.ExtractGceResourceAttributes(platform).ToDictionary(x => x.Key, x => x.Value); + var attrs = GcpResourceDetector.ExtractGceResourceAttributes(platform).ToDictionary(x => x.Key, x => x.Value); Assert.NotNull(attrs); Assert.Equal(4, attrs.Count); Assert.Equal(ResourceAttributeConstants.GcpCloudProviderValue, attrs[ResourceSemanticConventions.AttributeCloudProvider]); diff --git a/test/OpenTelemetry.ResourceDetectors.GCP.Tests/GlobalUsings.cs b/test/OpenTelemetry.ResourceDetectors.Gcp.Tests/GlobalUsings.cs similarity index 100% rename from test/OpenTelemetry.ResourceDetectors.GCP.Tests/GlobalUsings.cs rename to test/OpenTelemetry.ResourceDetectors.Gcp.Tests/GlobalUsings.cs diff --git a/test/OpenTelemetry.ResourceDetectors.GCP.Tests/OpenTelemetry.ResourceDetectors.GCP.Tests.csproj b/test/OpenTelemetry.ResourceDetectors.Gcp.Tests/OpenTelemetry.ResourceDetectors.Gcp.Tests.csproj similarity index 91% rename from test/OpenTelemetry.ResourceDetectors.GCP.Tests/OpenTelemetry.ResourceDetectors.GCP.Tests.csproj rename to test/OpenTelemetry.ResourceDetectors.Gcp.Tests/OpenTelemetry.ResourceDetectors.Gcp.Tests.csproj index 251f1668b1..afbf8bef31 100644 --- a/test/OpenTelemetry.ResourceDetectors.GCP.Tests/OpenTelemetry.ResourceDetectors.GCP.Tests.csproj +++ b/test/OpenTelemetry.ResourceDetectors.Gcp.Tests/OpenTelemetry.ResourceDetectors.Gcp.Tests.csproj @@ -12,7 +12,7 @@ - + From 6fbf780c3042c1e21d7e942f966caa4561b92de0 Mon Sep 17 00:00:00 2001 From: Matthew Hensley Date: Wed, 24 Apr 2024 14:16:15 -0400 Subject: [PATCH 06/33] mirror existing CI setup --- .github/codecov.yml | 5 +++++ .github/workflows/ci.yml | 16 ++++++++++++++ .../package-ResourceDetectors.Gcp.yml | 21 +++++++++++++++++++ 3 files changed, 42 insertions(+) create mode 100644 .github/workflows/package-ResourceDetectors.Gcp.yml diff --git a/.github/codecov.yml b/.github/codecov.yml index c38a11945c..105b8ef9f3 100644 --- a/.github/codecov.yml +++ b/.github/codecov.yml @@ -104,6 +104,11 @@ flags: paths: - src/OpenTelemetry.ResourceDetectors.Azure + unittests-ResourceDetectors.Gcp: + carryforward: true + paths: + - src/OpenTelemetry.ResourceDetectors.Gcp + unittests-ResourceDetectors.Host: carryforward: true paths: diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 417259c488..d728f9bac6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,6 +29,7 @@ jobs: eventcounters: ['*/OpenTelemetry.Instrumentation.EventCounters*/**', 'examples/event-counters/**', '!**/*.md'] extensions: ['*/OpenTelemetry.Extensions/**', '*/OpenTelemetry.Extensions.Tests/**', '!**/*.md'] geneva: ['*/OpenTelemetry.Exporter.Geneva*/**', '!**/*.md'] + gcp: ['*/OpenTelemetry.ResourceDetectors.Gcp*/**', '!**/*.md'] host: ['*/OpenTelemetry.ResourceDetectors.Host*/**', '!**/*.md'] onecollector: ['*/OpenTelemetry.Instrumentation.OneCollector*/**', '!**/*.md'] owin: ['*/OpenTelemetry.Instrumentation.Owin*/**', 'examples/owin/**', '!**/*.md'] @@ -49,6 +50,7 @@ jobs: '!*/OpenTelemetry.Instrumentation.AspNet*/**', '!examples/AspNet/**', '!*/OpenTelemetry.ResourceDetectors.Azure*/**', + '!*/OpenTelemetry.ResourceDetectors.Gcp*/**', '!*/OpenTelemetry.ResourceDetectors.Host*/**', '!*/OpenTelemetry.ResourceDetectors.Process/**', '!*/OpenTelemetry.ResourceDetectors.Process.Tests/**', @@ -147,6 +149,17 @@ jobs: project-name: OpenTelemetry.Exporter.Geneva code-cov-name: Exporter.Geneva + build-test-gcp: + needs: detect-changes + if: | + contains(needs.detect-changes.outputs.changes, 'gcp') + || contains(needs.detect-changes.outputs.changes, 'build') + || contains(needs.detect-changes.outputs.changes, 'shared') + uses: ./.github/workflows/Component.BuildTest.yml + with: + project-name: OpenTelemetry.ResourceDetectors.Gcp + code-cov-name: ResourceDetectors.Gcp + build-test-host: needs: detect-changes if: | @@ -321,6 +334,7 @@ jobs: OpenTelemetry.Instrumentation.Wcf.Tests.csproj, OpenTelemetry.PersistentStorage.FileSystem.Tests.csproj, OpenTelemetry.ResourceDetectors.Azure.Tests.csproj, + OpenTelemetry.ResourceDetectors.Gcp.Tests.csproj, OpenTelemetry.ResourceDetectors.Host.Tests.csproj, OpenTelemetry.ResourceDetectors.Process.Tests.csproj, OpenTelemetry.ResourceDetectors.ProcessRuntime.Tests.csproj @@ -369,6 +383,7 @@ jobs: || contains(needs.detect-changes.outputs.changes, 'aws') || contains(needs.detect-changes.outputs.changes, 'azure') || contains(needs.detect-changes.outputs.changes, 'extensions') + || contains(needs.detect-changes.outputs.changes, 'gcp') || contains(needs.detect-changes.outputs.changes, 'host') || contains(needs.detect-changes.outputs.changes, 'processdetector') || contains(needs.detect-changes.outputs.changes, 'processruntime') @@ -394,6 +409,7 @@ jobs: build-test-eventcounters, build-test-extensions, build-test-geneva, + build-test-gcp, build-test-host, build-test-onecollector, build-test-owin, diff --git a/.github/workflows/package-ResourceDetectors.Gcp.yml b/.github/workflows/package-ResourceDetectors.Gcp.yml new file mode 100644 index 0000000000..c79806c59d --- /dev/null +++ b/.github/workflows/package-ResourceDetectors.Gcp.yml @@ -0,0 +1,21 @@ +name: Pack OpenTelemetry.ResourceDetectors.Gcp + +on: + workflow_dispatch: + inputs: + logLevel: + description: 'Log level' + required: true + default: 'warning' + push: + tags: + - 'ResourceDetectors.Gcp-*' # trigger when we create a tag with prefix "ResourceDetectors.Gcp-" + +jobs: + call-build-test-pack: + permissions: + contents: write + uses: ./.github/workflows/Component.Package.yml + with: + project-name: OpenTelemetry.ResourceDetectors.Gcp + secrets: inherit From 4e305aec5231c30d5607fc1f578539d117401654 Mon Sep 17 00:00:00 2001 From: Matthew Hensley Date: Wed, 24 Apr 2024 14:29:48 -0400 Subject: [PATCH 07/33] add missing host.id attribute --- src/OpenTelemetry.ResourceDetectors.Gcp/GcpResourceDetector.cs | 1 + .../GcpResourceDetectorTests.cs | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/OpenTelemetry.ResourceDetectors.Gcp/GcpResourceDetector.cs b/src/OpenTelemetry.ResourceDetectors.Gcp/GcpResourceDetector.cs index dd739e527c..6b50ab1fb7 100644 --- a/src/OpenTelemetry.ResourceDetectors.Gcp/GcpResourceDetector.cs +++ b/src/OpenTelemetry.ResourceDetectors.Gcp/GcpResourceDetector.cs @@ -43,6 +43,7 @@ internal static List> ExtractGkeResourceAttributes( new(ResourceSemanticConventions.AttributeCloudAccount, platform.ProjectId), new(ResourceSemanticConventions.AttributeCloudPlatform, ResourceAttributeConstants.GcpGkePlatformValue), new(ResourceSemanticConventions.AttributeCloudZone, platform.GkeDetails.Zone), + new(ResourceSemanticConventions.AttributeHostId, platform.GkeDetails.InstanceId), new(ResourceSemanticConventions.AttributeK8sCluster, platform.GkeDetails.ClusterName), new(ResourceSemanticConventions.AttributeK8sNamespace, platform.GkeDetails.NamespaceId), new(ResourceSemanticConventions.AttributeK8sPod, platform.GkeDetails.HostName), diff --git a/test/OpenTelemetry.ResourceDetectors.Gcp.Tests/GcpResourceDetectorTests.cs b/test/OpenTelemetry.ResourceDetectors.Gcp.Tests/GcpResourceDetectorTests.cs index 86264ecdfe..c9a81c2274 100644 --- a/test/OpenTelemetry.ResourceDetectors.Gcp.Tests/GcpResourceDetectorTests.cs +++ b/test/OpenTelemetry.ResourceDetectors.Gcp.Tests/GcpResourceDetectorTests.cs @@ -27,11 +27,12 @@ public void TestExtractGkeResourceAttributes() var platform = new Platform(details); var attrs = GcpResourceDetector.ExtractGkeResourceAttributes(platform).ToDictionary(x => x.Key, x => x.Value); Assert.NotNull(attrs); - Assert.Equal(7, attrs.Count); + Assert.Equal(8, attrs.Count); Assert.Equal(ResourceAttributeConstants.GcpCloudProviderValue, attrs[ResourceSemanticConventions.AttributeCloudProvider]); Assert.Equal("projectId", attrs[ResourceSemanticConventions.AttributeCloudAccount]); Assert.Equal(ResourceAttributeConstants.GcpGkePlatformValue, attrs[ResourceSemanticConventions.AttributeCloudPlatform]); Assert.Equal("us-central1-a", attrs[ResourceSemanticConventions.AttributeCloudZone]); + Assert.Equal("instanceId", attrs[ResourceSemanticConventions.AttributeHostId]); Assert.Equal("clusterName", attrs[ResourceSemanticConventions.AttributeK8sCluster]); Assert.Equal("namespaceId", attrs[ResourceSemanticConventions.AttributeK8sNamespace]); Assert.Equal("hostName", attrs[ResourceSemanticConventions.AttributeK8sPod]); From 919e64f7140a0188737cafc163007f027cf8b91e Mon Sep 17 00:00:00 2001 From: Matthew Hensley Date: Wed, 24 Apr 2024 15:57:04 -0400 Subject: [PATCH 08/33] WIP README --- .../README.md | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/OpenTelemetry.ResourceDetectors.Gcp/README.md b/src/OpenTelemetry.ResourceDetectors.Gcp/README.md index eb2a463032..581dda80a6 100644 --- a/src/OpenTelemetry.ResourceDetectors.Gcp/README.md +++ b/src/OpenTelemetry.ResourceDetectors.Gcp/README.md @@ -1,6 +1,6 @@ # Resource Detectors for Google Cloud Platform environments -[![NuGet version badge](https://img.shields.io/nuget/v/OpenTelemetry.ResourceDetectors.GCP)](https://www.nuget.org/packages/OpenTelemetry.ResourceDetectors.GCP) +[![NuGet version badge](https://img.shields.io/nuget/v/OpenTelemetry.ResourceDetectors.Gcp)](https://www.nuget.org/packages/OpenTelemetry.ResourceDetectors.Gcp) [![NuGet download count badge](https://img.shields.io/nuget/dt/OpenTelemetry.ResourceDetectors.Azure)](https://www.nuget.org/packages/OpenTelemetry.ResourceDetectors.Azure) This package contains [Resource @@ -10,5 +10,20 @@ for applications running in Google Cloud Platform environments. ## Installation ```shell -dotnet add package --prerelease OpenTelemetry.ResourceDetectors.GCP +dotnet add package --prerelease OpenTelemetry.ResourceDetectors.Gcp ``` + +## Resource Attributes + +The following OpenTelemetry semantic conventions will be detected: + +|--------------------|------|------|------|------| +| Resource Attribute | GKE | GAE | GCR | GCE | +| cloud.provider | gcp | gcp | gcp | gcp | +| cloud.platform | gcp_kubernetes_engine | gcp_app_engine | gcp_cloud_run | gcp_compute_engine | +| cloud.account.id | auto | auto | auto | auto | +| cloud.zone | auto | | auto | | +| host.id | auto | | | auto | +| k8s.cluster.name | auto | | | | +| k8s.namespace.name | auto | | | | +| k8s.pod.name | auto | | | | From 566677eeb1c6a16002f57425bc802301f77a50f2 Mon Sep 17 00:00:00 2001 From: Matthew Hensley Date: Wed, 24 Apr 2024 16:04:57 -0400 Subject: [PATCH 09/33] CHANGELOG entry --- src/OpenTelemetry.ResourceDetectors.Gcp/CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/OpenTelemetry.ResourceDetectors.Gcp/CHANGELOG.md b/src/OpenTelemetry.ResourceDetectors.Gcp/CHANGELOG.md index 617d979ab2..e83c4c50bc 100644 --- a/src/OpenTelemetry.ResourceDetectors.Gcp/CHANGELOG.md +++ b/src/OpenTelemetry.ResourceDetectors.Gcp/CHANGELOG.md @@ -2,3 +2,7 @@ ## Unreleased +* Add Google Cloud Platform resource detector for GKE, GAE, GCR, and GCE. + ([#1691](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/1691)) + +For more details, please refer to the [README](README.md). From 105ee7e4d8b423ef795a84266141aee6d6c4278e Mon Sep 17 00:00:00 2001 From: Matthew Hensley Date: Wed, 24 Apr 2024 16:09:37 -0400 Subject: [PATCH 10/33] code example --- src/OpenTelemetry.ResourceDetectors.Gcp/README.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/OpenTelemetry.ResourceDetectors.Gcp/README.md b/src/OpenTelemetry.ResourceDetectors.Gcp/README.md index 581dda80a6..6d8750c0de 100644 --- a/src/OpenTelemetry.ResourceDetectors.Gcp/README.md +++ b/src/OpenTelemetry.ResourceDetectors.Gcp/README.md @@ -13,6 +13,17 @@ for applications running in Google Cloud Platform environments. dotnet add package --prerelease OpenTelemetry.ResourceDetectors.Gcp ``` +```csharp +using OpenTelemetry; +using OpenTelemetry.ResourceDetectors.Gcp; +using OpenTelemetry.Resources; + +var tracerProvider = Sdk.CreateTracerProviderBuilder() + // other configurations + .ConfigureResource(resource => resource.AddDetector(new GcpResourceDetector())) + .Build(); +``` + ## Resource Attributes The following OpenTelemetry semantic conventions will be detected: From ba4f7f941c620647f3fc70d16bebd7a9c79b6cee Mon Sep 17 00:00:00 2001 From: Matthew Hensley Date: Wed, 24 Apr 2024 16:34:29 -0400 Subject: [PATCH 11/33] update to AZ attribute --- .../GcpResourceDetector.cs | 4 +++- .../README.md | 21 ++++++++++--------- src/Shared/ResourceSemanticConventions.cs | 1 + .../GcpResourceDetectorTests.cs | 9 ++++---- 4 files changed, 20 insertions(+), 15 deletions(-) diff --git a/src/OpenTelemetry.ResourceDetectors.Gcp/GcpResourceDetector.cs b/src/OpenTelemetry.ResourceDetectors.Gcp/GcpResourceDetector.cs index 6b50ab1fb7..529154dfde 100644 --- a/src/OpenTelemetry.ResourceDetectors.Gcp/GcpResourceDetector.cs +++ b/src/OpenTelemetry.ResourceDetectors.Gcp/GcpResourceDetector.cs @@ -58,8 +58,9 @@ internal static List> ExtractCloudRunResourceAttrib { new(ResourceSemanticConventions.AttributeCloudProvider, ResourceAttributeConstants.GcpCloudProviderValue), new(ResourceSemanticConventions.AttributeCloudAccount, platform.ProjectId), + new(ResourceSemanticConventions.AttributeCloudAvailabilityZone, platform.CloudRunDetails.Zone), new(ResourceSemanticConventions.AttributeCloudPlatform, ResourceAttributeConstants.GcpCloudRunPlatformValue), - new(ResourceSemanticConventions.AttributeCloudZone, platform.CloudRunDetails.Zone), + new(ResourceSemanticConventions.AttributeCloudRegion, platform.CloudRunDetails.Region), }; return attributeList; @@ -84,6 +85,7 @@ internal static List> ExtractGceResourceAttributes( new(ResourceSemanticConventions.AttributeCloudAccount, platform.ProjectId), new(ResourceSemanticConventions.AttributeCloudPlatform, ResourceAttributeConstants.GcpGcePlatformValue), new(ResourceSemanticConventions.AttributeHostId, platform.GceDetails.InstanceId), + new(ResourceSemanticConventions.AttributeCloudAvailabilityZone, platform.GceDetails.Location), }; return attributeList; diff --git a/src/OpenTelemetry.ResourceDetectors.Gcp/README.md b/src/OpenTelemetry.ResourceDetectors.Gcp/README.md index 6d8750c0de..c54fc7a539 100644 --- a/src/OpenTelemetry.ResourceDetectors.Gcp/README.md +++ b/src/OpenTelemetry.ResourceDetectors.Gcp/README.md @@ -28,13 +28,14 @@ var tracerProvider = Sdk.CreateTracerProviderBuilder() The following OpenTelemetry semantic conventions will be detected: -|--------------------|------|------|------|------| -| Resource Attribute | GKE | GAE | GCR | GCE | -| cloud.provider | gcp | gcp | gcp | gcp | -| cloud.platform | gcp_kubernetes_engine | gcp_app_engine | gcp_cloud_run | gcp_compute_engine | -| cloud.account.id | auto | auto | auto | auto | -| cloud.zone | auto | | auto | | -| host.id | auto | | | auto | -| k8s.cluster.name | auto | | | | -| k8s.namespace.name | auto | | | | -| k8s.pod.name | auto | | | | +|-------------------------|------|------|------|------| +| Resource Attribute | GKE | GAE | GCR | GCE | +| cloud.provider | gcp | gcp | gcp | gcp | +| cloud.platform | gcp_kubernetes_engine | gcp_app_engine | gcp_cloud_run | gcp_compute_engine | +| cloud.account.id | auto | auto | auto | auto | +| cloud.availability_zone | auto | | auto | auto | +| cloud.region | | | auto | | +| host.id | auto | | | auto | +| k8s.cluster.name | auto | | | | +| k8s.namespace.name | auto | | | | +| k8s.pod.name | auto | | | | diff --git a/src/Shared/ResourceSemanticConventions.cs b/src/Shared/ResourceSemanticConventions.cs index 4b4aa6a9ea..22903d04bc 100644 --- a/src/Shared/ResourceSemanticConventions.cs +++ b/src/Shared/ResourceSemanticConventions.cs @@ -44,6 +44,7 @@ internal static class ResourceSemanticConventions public const string AttributeProcessUsername = "process.username"; public const string AttributeCloudAccount = "cloud.account.id"; + public const string AttributeCloudAvailabilityZone = "cloud.availability_zone"; public const string AttributeCloudPlatform = "cloud.platform"; public const string AttributeCloudProvider = "cloud.provider"; public const string AttributeCloudRegion = "cloud.region"; diff --git a/test/OpenTelemetry.ResourceDetectors.Gcp.Tests/GcpResourceDetectorTests.cs b/test/OpenTelemetry.ResourceDetectors.Gcp.Tests/GcpResourceDetectorTests.cs index c9a81c2274..e34c436adc 100644 --- a/test/OpenTelemetry.ResourceDetectors.Gcp.Tests/GcpResourceDetectorTests.cs +++ b/test/OpenTelemetry.ResourceDetectors.Gcp.Tests/GcpResourceDetectorTests.cs @@ -51,11 +51,12 @@ public void TestExtractCloudRunResourceAttributes() var platform = new Platform(details); var attrs = GcpResourceDetector.ExtractCloudRunResourceAttributes(platform).ToDictionary(x => x.Key, x => x.Value); Assert.NotNull(attrs); - Assert.Equal(4, attrs.Count); + Assert.Equal(5, attrs.Count); Assert.Equal(ResourceAttributeConstants.GcpCloudProviderValue, attrs[ResourceSemanticConventions.AttributeCloudProvider]); Assert.Equal("projectId", attrs[ResourceSemanticConventions.AttributeCloudAccount]); + Assert.Equal("us-central1-a", attrs[ResourceSemanticConventions.AttributeCloudAvailabilityZone]); Assert.Equal(ResourceAttributeConstants.GcpCloudRunPlatformValue, attrs[ResourceSemanticConventions.AttributeCloudPlatform]); - Assert.Equal("us-central1-a", attrs[ResourceSemanticConventions.AttributeCloudZone]); + Assert.Equal("us-central1", attrs[ResourceSemanticConventions.AttributeCloudRegion]); } [Fact] @@ -82,11 +83,11 @@ public void TestExtractGceResourceAttributes() metadataJson: "json", projectId: "projectId", instanceId: "instanceId", - zoneName: "us-central1-a"); + zoneName: "projects/12345/zones/us-central1-a"); var platform = new Platform(details); var attrs = GcpResourceDetector.ExtractGceResourceAttributes(platform).ToDictionary(x => x.Key, x => x.Value); Assert.NotNull(attrs); - Assert.Equal(4, attrs.Count); + Assert.Equal(5, attrs.Count); Assert.Equal(ResourceAttributeConstants.GcpCloudProviderValue, attrs[ResourceSemanticConventions.AttributeCloudProvider]); Assert.Equal("projectId", attrs[ResourceSemanticConventions.AttributeCloudAccount]); Assert.Equal(ResourceAttributeConstants.GcpGcePlatformValue, attrs[ResourceSemanticConventions.AttributeCloudPlatform]); From fbf0300426b69f137f75fb58e72f9e2b70a02058 Mon Sep 17 00:00:00 2001 From: Matthew Hensley Date: Tue, 30 Apr 2024 16:01:59 -0400 Subject: [PATCH 12/33] fix formatting --- src/OpenTelemetry.ResourceDetectors.Gcp/GcpResourceDetector.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/OpenTelemetry.ResourceDetectors.Gcp/GcpResourceDetector.cs b/src/OpenTelemetry.ResourceDetectors.Gcp/GcpResourceDetector.cs index 529154dfde..b0d9043eb0 100644 --- a/src/OpenTelemetry.ResourceDetectors.Gcp/GcpResourceDetector.cs +++ b/src/OpenTelemetry.ResourceDetectors.Gcp/GcpResourceDetector.cs @@ -78,7 +78,7 @@ internal static List> ExtractGaeResourceAttributes( } internal static List> ExtractGceResourceAttributes(Platform platform) -{ + { List> attributeList = new() { new(ResourceSemanticConventions.AttributeCloudProvider, ResourceAttributeConstants.GcpCloudProviderValue), From 8eab542c5ae1479f3f317276e2437dcf08f104bb Mon Sep 17 00:00:00 2001 From: Matthew Hensley Date: Tue, 30 Apr 2024 16:09:35 -0400 Subject: [PATCH 13/33] rework attribute listing --- .../README.md | 56 ++++++++++++++----- 1 file changed, 43 insertions(+), 13 deletions(-) diff --git a/src/OpenTelemetry.ResourceDetectors.Gcp/README.md b/src/OpenTelemetry.ResourceDetectors.Gcp/README.md index c54fc7a539..334455e67f 100644 --- a/src/OpenTelemetry.ResourceDetectors.Gcp/README.md +++ b/src/OpenTelemetry.ResourceDetectors.Gcp/README.md @@ -26,16 +26,46 @@ var tracerProvider = Sdk.CreateTracerProviderBuilder() ## Resource Attributes -The following OpenTelemetry semantic conventions will be detected: - -|-------------------------|------|------|------|------| -| Resource Attribute | GKE | GAE | GCR | GCE | -| cloud.provider | gcp | gcp | gcp | gcp | -| cloud.platform | gcp_kubernetes_engine | gcp_app_engine | gcp_cloud_run | gcp_compute_engine | -| cloud.account.id | auto | auto | auto | auto | -| cloud.availability_zone | auto | | auto | auto | -| cloud.region | | | auto | | -| host.id | auto | | | auto | -| k8s.cluster.name | auto | | | | -| k8s.namespace.name | auto | | | | -| k8s.pod.name | auto | | | | +The following OpenTelemetry semantic conventions will be detected depending on +which Google Cloud Platform environment an application is running in. + +### Google Kubernetes Engine + +|-------------------------|-----------------------| +| Attribute | Value | +| cloud.provider | gcp | +| cloud.platform | gcp_kubernetes_engine | +| cloud.account.id | auto | +| cloud.availability_zone | auto | +| host.id | auto | +| k8s.cluster.name | auto | +| k8s.namespace.name | auto | +| k8s.pod.name | auto | + +### Google App Engine + +|-------------------------|----------------| +| Attribute | Value | +| cloud.provider | gcp | +| cloud.platform | gcp_app_engine | +| cloud.account.id | auto | + +### Google Cloud Run + +|-------------------------|---------------| +| Attribute | Value | +| cloud.provider | gcp | +| cloud.platform | gcp_cloud_run | +| cloud.account.id | auto | +| cloud.availability_zone | auto | +| cloud.region | auto | + +### Google Compute Engine + +|-------------------------|--------------------| +| Attribute | Value | +| cloud.provider | gcp | +| cloud.platform | gcp_compute_engine | +| cloud.account.id | auto | +| cloud.availability_zone | auto | +| host.id | auto | From 063aff70dad9aa0fbc9c3710fd2edc8391e433dd Mon Sep 17 00:00:00 2001 From: Matthew Hensley Date: Tue, 30 Apr 2024 21:23:00 -0400 Subject: [PATCH 14/33] missing solution section --- opentelemetry-dotnet-contrib.sln | 1 + 1 file changed, 1 insertion(+) diff --git a/opentelemetry-dotnet-contrib.sln b/opentelemetry-dotnet-contrib.sln index bba6583321..789852d197 100644 --- a/opentelemetry-dotnet-contrib.sln +++ b/opentelemetry-dotnet-contrib.sln @@ -331,6 +331,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Projects", "Projects", "{04 build\Projects\OpenTelemetry.Instrumentation.Wcf.proj = build\Projects\OpenTelemetry.Instrumentation.Wcf.proj build\Projects\OpenTelemetry.PersistentStorage.proj = build\Projects\OpenTelemetry.PersistentStorage.proj build\Projects\OpenTelemetry.ResourceDetectors.Azure.proj = build\Projects\OpenTelemetry.ResourceDetectors.Azure.proj + build\Projects\OpenTelemetry.ResourceDetectors.Gcp.proj = build\Projects\OpenTelemetry.ResourceDetectors.Gcp.proj build\Projects\OpenTelemetry.ResourceDetectors.Host.proj = build\Projects\OpenTelemetry.ResourceDetectors.Host.proj build\Projects\OpenTelemetry.ResourceDetectors.Process.proj = build\Projects\OpenTelemetry.ResourceDetectors.Process.proj build\Projects\OpenTelemetry.ResourceDetectors.ProcessRuntime.proj = build\Projects\OpenTelemetry.ResourceDetectors.ProcessRuntime.proj From a526638daf35465732b346607baf9c50c74b6935 Mon Sep 17 00:00:00 2001 From: Matthew Hensley Date: Tue, 30 Apr 2024 21:26:40 -0400 Subject: [PATCH 15/33] missing proj --- .../OpenTelemetry.ResourceDetectors.Gcp.proj | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 build/Projects/OpenTelemetry.ResourceDetectors.Gcp.proj diff --git a/build/Projects/OpenTelemetry.ResourceDetectors.Gcp.proj b/build/Projects/OpenTelemetry.ResourceDetectors.Gcp.proj new file mode 100644 index 0000000000..c891a6205c --- /dev/null +++ b/build/Projects/OpenTelemetry.ResourceDetectors.Gcp.proj @@ -0,0 +1,32 @@ + + + + $([System.IO.Directory]::GetParent($(MSBuildThisFileDirectory)).Parent.Parent.FullName) + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 2d2f2deb94a93b8c82d7f6b28486b24bd7b767de Mon Sep 17 00:00:00 2001 From: Matthew Hensley Date: Wed, 1 May 2024 10:29:52 -0400 Subject: [PATCH 16/33] resource builder extension method --- .../.publicApi/net6.0/PublicAPI.Unshipped.txt | 2 ++ .../netstandard2.0/PublicAPI.Unshipped.txt | 2 ++ .../GcpResourceBuilderExtensions.cs | 24 +++++++++++++++++++ .../README.md | 3 +-- 4 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 src/OpenTelemetry.ResourceDetectors.Gcp/GcpResourceBuilderExtensions.cs diff --git a/src/OpenTelemetry.ResourceDetectors.Gcp/.publicApi/net6.0/PublicAPI.Unshipped.txt b/src/OpenTelemetry.ResourceDetectors.Gcp/.publicApi/net6.0/PublicAPI.Unshipped.txt index 45c069df18..4669de906b 100644 --- a/src/OpenTelemetry.ResourceDetectors.Gcp/.publicApi/net6.0/PublicAPI.Unshipped.txt +++ b/src/OpenTelemetry.ResourceDetectors.Gcp/.publicApi/net6.0/PublicAPI.Unshipped.txt @@ -1,3 +1,5 @@ OpenTelemetry.ResourceDetectors.Gcp.GcpResourceDetector OpenTelemetry.ResourceDetectors.Gcp.GcpResourceDetector.GcpResourceDetector() -> void OpenTelemetry.ResourceDetectors.Gcp.GcpResourceDetector.Detect() -> OpenTelemetry.Resources.Resource! +OpenTelemetry.Resources.GcpResourceBuilderExtensions +static OpenTelemetry.Resources.GcpResourceBuilderExtensions.AddGcpDetector(this OpenTelemetry.Resources.ResourceBuilder! builder) -> OpenTelemetry.Resources.ResourceBuilder! diff --git a/src/OpenTelemetry.ResourceDetectors.Gcp/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt b/src/OpenTelemetry.ResourceDetectors.Gcp/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt index 45c069df18..4669de906b 100644 --- a/src/OpenTelemetry.ResourceDetectors.Gcp/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt +++ b/src/OpenTelemetry.ResourceDetectors.Gcp/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt @@ -1,3 +1,5 @@ OpenTelemetry.ResourceDetectors.Gcp.GcpResourceDetector OpenTelemetry.ResourceDetectors.Gcp.GcpResourceDetector.GcpResourceDetector() -> void OpenTelemetry.ResourceDetectors.Gcp.GcpResourceDetector.Detect() -> OpenTelemetry.Resources.Resource! +OpenTelemetry.Resources.GcpResourceBuilderExtensions +static OpenTelemetry.Resources.GcpResourceBuilderExtensions.AddGcpDetector(this OpenTelemetry.Resources.ResourceBuilder! builder) -> OpenTelemetry.Resources.ResourceBuilder! diff --git a/src/OpenTelemetry.ResourceDetectors.Gcp/GcpResourceBuilderExtensions.cs b/src/OpenTelemetry.ResourceDetectors.Gcp/GcpResourceBuilderExtensions.cs new file mode 100644 index 0000000000..9a04495c76 --- /dev/null +++ b/src/OpenTelemetry.ResourceDetectors.Gcp/GcpResourceBuilderExtensions.cs @@ -0,0 +1,24 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +using OpenTelemetry.Internal; +using OpenTelemetry.ResourceDetectors.Gcp; + +namespace OpenTelemetry.Resources; + +/// +/// Extension methods to simplify registering of Google Cloud Platform resource detectors. +/// +public static class GcpResourceBuilderExtensions +{ + /// + /// Enables Google Cloud Platform resource detector. + /// + /// being configured. + /// The instance of being configured. + public static ResourceBuilder AddGcpDetector(this ResourceBuilder builder) + { + Guard.ThrowIfNull(builder); + return builder.AddDetector(new GcpResourceDetector()); + } +} diff --git a/src/OpenTelemetry.ResourceDetectors.Gcp/README.md b/src/OpenTelemetry.ResourceDetectors.Gcp/README.md index 334455e67f..0b100dbd67 100644 --- a/src/OpenTelemetry.ResourceDetectors.Gcp/README.md +++ b/src/OpenTelemetry.ResourceDetectors.Gcp/README.md @@ -15,12 +15,11 @@ dotnet add package --prerelease OpenTelemetry.ResourceDetectors.Gcp ```csharp using OpenTelemetry; -using OpenTelemetry.ResourceDetectors.Gcp; using OpenTelemetry.Resources; var tracerProvider = Sdk.CreateTracerProviderBuilder() // other configurations - .ConfigureResource(resource => resource.AddDetector(new GcpResourceDetector())) + .ConfigureResource(resource => resource.AddGcpDetector()) .Build(); ``` From e84b13fb236874f10d5aee7890a10004f00cf2d7 Mon Sep 17 00:00:00 2001 From: Matthew Hensley Date: Wed, 1 May 2024 12:59:38 -0400 Subject: [PATCH 17/33] rename per #1610 --- .github/codecov.yml | 2 +- .github/workflows/ci.yml | 12 ++++++------ .github/workflows/package-ResourceDetectors.Gcp.yml | 6 +++--- .../OpenTelemetry.ResourceDetectors.Gcp.proj | 8 ++++---- opentelemetry-dotnet-contrib.sln | 6 +++--- .../.publicApi/net6.0/PublicAPI.Unshipped.txt | 5 ----- .../netstandard2.0/PublicAPI.Unshipped.txt | 5 ----- .../AssemblyInfo.cs | 10 ---------- .../.publicApi/net6.0/PublicAPI.Shipped.txt | 0 .../.publicApi/net6.0/PublicAPI.Unshipped.txt | 5 +++++ .../.publicApi/netstandard2.0/PublicAPI.Shipped.txt | 0 .../netstandard2.0/PublicAPI.Unshipped.txt | 5 +++++ src/OpenTelemetry.Resources.Gcp/AssemblyInfo.cs | 10 ++++++++++ .../CHANGELOG.md | 0 .../GcpResourceBuilderExtensions.cs | 2 +- .../GcpResourceDetector.cs | 2 +- .../OpenTelemetry.Resources.Gcp.csproj} | 2 +- .../README.md | 4 ++-- .../ResourceAttributeConstants.cs | 2 +- .../GcpResourceDetectorTests.cs | 2 +- .../GlobalUsings.cs | 0 .../OpenTelemetry.Resources.Gcp.Tests.csproj} | 2 +- 22 files changed, 45 insertions(+), 45 deletions(-) delete mode 100644 src/OpenTelemetry.ResourceDetectors.Gcp/.publicApi/net6.0/PublicAPI.Unshipped.txt delete mode 100644 src/OpenTelemetry.ResourceDetectors.Gcp/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt delete mode 100644 src/OpenTelemetry.ResourceDetectors.Gcp/AssemblyInfo.cs rename src/{OpenTelemetry.ResourceDetectors.Gcp => OpenTelemetry.Resources.Gcp}/.publicApi/net6.0/PublicAPI.Shipped.txt (100%) create mode 100644 src/OpenTelemetry.Resources.Gcp/.publicApi/net6.0/PublicAPI.Unshipped.txt rename src/{OpenTelemetry.ResourceDetectors.Gcp => OpenTelemetry.Resources.Gcp}/.publicApi/netstandard2.0/PublicAPI.Shipped.txt (100%) create mode 100644 src/OpenTelemetry.Resources.Gcp/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt create mode 100644 src/OpenTelemetry.Resources.Gcp/AssemblyInfo.cs rename src/{OpenTelemetry.ResourceDetectors.Gcp => OpenTelemetry.Resources.Gcp}/CHANGELOG.md (100%) rename src/{OpenTelemetry.ResourceDetectors.Gcp => OpenTelemetry.Resources.Gcp}/GcpResourceBuilderExtensions.cs (94%) rename src/{OpenTelemetry.ResourceDetectors.Gcp => OpenTelemetry.Resources.Gcp}/GcpResourceDetector.cs (98%) rename src/{OpenTelemetry.ResourceDetectors.Gcp/OpenTelemetry.ResourceDetectors.Gcp.csproj => OpenTelemetry.Resources.Gcp/OpenTelemetry.Resources.Gcp.csproj} (93%) rename src/{OpenTelemetry.ResourceDetectors.Gcp => OpenTelemetry.Resources.Gcp}/README.md (93%) rename src/{OpenTelemetry.ResourceDetectors.Gcp => OpenTelemetry.Resources.Gcp}/ResourceAttributeConstants.cs (91%) rename test/{OpenTelemetry.ResourceDetectors.Gcp.Tests => OpenTelemetry.Resources.Gcp.Tests}/GcpResourceDetectorTests.cs (98%) rename test/{OpenTelemetry.ResourceDetectors.Gcp.Tests => OpenTelemetry.Resources.Gcp.Tests}/GlobalUsings.cs (100%) rename test/{OpenTelemetry.ResourceDetectors.Gcp.Tests/OpenTelemetry.ResourceDetectors.Gcp.Tests.csproj => OpenTelemetry.Resources.Gcp.Tests/OpenTelemetry.Resources.Gcp.Tests.csproj} (91%) diff --git a/.github/codecov.yml b/.github/codecov.yml index 5b4a53b5df..6ae6cc15c3 100644 --- a/.github/codecov.yml +++ b/.github/codecov.yml @@ -112,7 +112,7 @@ flags: unittests-ResourceDetectors.Gcp: carryforward: true paths: - - src/OpenTelemetry.ResourceDetectors.Gcp + - src/OpenTelemetry.Resources.Gcp unittests-ResourceDetectors.Host: carryforward: true diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3758c7aac7..8d2725dd96 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,7 +29,7 @@ jobs: eventcounters: ['*/OpenTelemetry.Instrumentation.EventCounters*/**', 'examples/event-counters/**', '!**/*.md'] extensions: ['*/OpenTelemetry.Extensions/**', '*/OpenTelemetry.Extensions.Tests/**', '!**/*.md'] geneva: ['*/OpenTelemetry.Exporter.Geneva*/**', '!**/*.md'] - gcp: ['*/OpenTelemetry.ResourceDetectors.Gcp*/**', '!**/*.md'] + gcp: ['*/OpenTelemetry.Resources.Gcp*/**', '!**/*.md'] host: ['*/OpenTelemetry.ResourceDetectors.Host*/**', '!**/*.md'] http: ['*/OpenTelemetry.Instrumentation.Http*/**', '!**/*.md'] onecollector: ['*/OpenTelemetry.Instrumentation.OneCollector*/**', '!**/*.md'] @@ -52,12 +52,12 @@ jobs: '!*/OpenTelemetry.Instrumentation.AspNet*/**', '!examples/AspNet/**', '!*/OpenTelemetry.ResourceDetectors.Azure*/**', - '!*/OpenTelemetry.ResourceDetectors.Gcp*/**', '!*/OpenTelemetry.ResourceDetectors.Host*/**', '!*/OpenTelemetry.ResourceDetectors.Process/**', '!*/OpenTelemetry.ResourceDetectors.Process.Tests/**', '!*/OpenTelemetry.ResourceDetectors.ProcessRuntime/**', '!*/OpenTelemetry.ResourceDetectors.ProcessRuntime.Tests/**', + '!*/OpenTelemetry.Resources.Gcp*/**', '!*/OpenTelemetry.Instrumentation.EventCounters*/**', '!examples/event-counters/**', '!*/OpenTelemetry.Extensions/**', @@ -161,8 +161,8 @@ jobs: || contains(needs.detect-changes.outputs.changes, 'shared') uses: ./.github/workflows/Component.BuildTest.yml with: - project-name: OpenTelemetry.ResourceDetectors.Gcp - code-cov-name: ResourceDetectors.Gcp + project-name: OpenTelemetry.Resources.Gcp + code-cov-name: Resources.Gcp build-test-host: needs: detect-changes @@ -361,10 +361,10 @@ jobs: OpenTelemetry.Instrumentation.Wcf.Tests.csproj, OpenTelemetry.PersistentStorage.FileSystem.Tests.csproj, OpenTelemetry.ResourceDetectors.Azure.Tests.csproj, - OpenTelemetry.ResourceDetectors.Gcp.Tests.csproj, OpenTelemetry.ResourceDetectors.Host.Tests.csproj, OpenTelemetry.ResourceDetectors.Process.Tests.csproj, - OpenTelemetry.ResourceDetectors.ProcessRuntime.Tests.csproj + OpenTelemetry.ResourceDetectors.ProcessRuntime.Tests.csproj, + OpenTelemetry.Resources.Gcp.Tests.csproj $failedProjects = @() diff --git a/.github/workflows/package-ResourceDetectors.Gcp.yml b/.github/workflows/package-ResourceDetectors.Gcp.yml index c79806c59d..a10b917607 100644 --- a/.github/workflows/package-ResourceDetectors.Gcp.yml +++ b/.github/workflows/package-ResourceDetectors.Gcp.yml @@ -1,4 +1,4 @@ -name: Pack OpenTelemetry.ResourceDetectors.Gcp +name: Pack OpenTelemetry.Resources.Gcp on: workflow_dispatch: @@ -9,7 +9,7 @@ on: default: 'warning' push: tags: - - 'ResourceDetectors.Gcp-*' # trigger when we create a tag with prefix "ResourceDetectors.Gcp-" + - 'Resources.Gcp-*' # trigger when we create a tag with prefix "Resources.Gcp-" jobs: call-build-test-pack: @@ -17,5 +17,5 @@ jobs: contents: write uses: ./.github/workflows/Component.Package.yml with: - project-name: OpenTelemetry.ResourceDetectors.Gcp + project-name: OpenTelemetry.Resources.Gcp secrets: inherit diff --git a/build/Projects/OpenTelemetry.ResourceDetectors.Gcp.proj b/build/Projects/OpenTelemetry.ResourceDetectors.Gcp.proj index c891a6205c..19364c3155 100644 --- a/build/Projects/OpenTelemetry.ResourceDetectors.Gcp.proj +++ b/build/Projects/OpenTelemetry.ResourceDetectors.Gcp.proj @@ -5,12 +5,12 @@ - - + + - + - + diff --git a/opentelemetry-dotnet-contrib.sln b/opentelemetry-dotnet-contrib.sln index 789852d197..66d040ce1b 100644 --- a/opentelemetry-dotnet-contrib.sln +++ b/opentelemetry-dotnet-contrib.sln @@ -331,10 +331,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Projects", "Projects", "{04 build\Projects\OpenTelemetry.Instrumentation.Wcf.proj = build\Projects\OpenTelemetry.Instrumentation.Wcf.proj build\Projects\OpenTelemetry.PersistentStorage.proj = build\Projects\OpenTelemetry.PersistentStorage.proj build\Projects\OpenTelemetry.ResourceDetectors.Azure.proj = build\Projects\OpenTelemetry.ResourceDetectors.Azure.proj - build\Projects\OpenTelemetry.ResourceDetectors.Gcp.proj = build\Projects\OpenTelemetry.ResourceDetectors.Gcp.proj build\Projects\OpenTelemetry.ResourceDetectors.Host.proj = build\Projects\OpenTelemetry.ResourceDetectors.Host.proj build\Projects\OpenTelemetry.ResourceDetectors.Process.proj = build\Projects\OpenTelemetry.ResourceDetectors.Process.proj build\Projects\OpenTelemetry.ResourceDetectors.ProcessRuntime.proj = build\Projects\OpenTelemetry.ResourceDetectors.ProcessRuntime.proj + build\Projects\OpenTelemetry.Resources.Gcp.proj = build\Projects\OpenTelemetry.Resources.Gcp.proj build\Projects\OpenTelemetry.SemanticConventions.proj = build\Projects\OpenTelemetry.SemanticConventions.proj EndProjectSection EndProject @@ -352,9 +352,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenTelemetry.ResourceDetec EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenTelemetry.PersistentStorage.Abstractions.Tests", "test\OpenTelemetry.PersistentStorage.Abstractions.Tests\OpenTelemetry.PersistentStorage.Abstractions.Tests.csproj", "{7AD707F9-DC6D-430A-8834-D5DCD517BF6E}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenTelemetry.ResourceDetectors.Gcp", "src\OpenTelemetry.ResourceDetectors.Gcp\OpenTelemetry.ResourceDetectors.Gcp.csproj", "{CBC6D677-D1FF-470E-A244-477E8616A245}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenTelemetry.Resources.Gcp", "src\OpenTelemetry.Resources.Gcp\OpenTelemetry.Resources.Gcp.csproj", "{CBC6D677-D1FF-470E-A244-477E8616A245}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenTelemetry.ResourceDetectors.Gcp.Tests", "test\OpenTelemetry.ResourceDetectors.Gcp.Tests\OpenTelemetry.ResourceDetectors.Gcp.Tests.csproj", "{EECE8D5F-C319-42E8-B37C-A41D6FF43E4A}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenTelemetry.Resources.Gcp.Tests", "test\OpenTelemetry.Resources.Gcp.Tests\OpenTelemetry.Resources.Gcp.Tests.csproj", "{EECE8D5F-C319-42E8-B37C-A41D6FF43E4A}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenTelemetry.Instrumentation.SqlClient", "src\OpenTelemetry.Instrumentation.SqlClient\OpenTelemetry.Instrumentation.SqlClient.csproj", "{737D1A9E-5A1A-4F4F-830B-E98ED100994C}" EndProject diff --git a/src/OpenTelemetry.ResourceDetectors.Gcp/.publicApi/net6.0/PublicAPI.Unshipped.txt b/src/OpenTelemetry.ResourceDetectors.Gcp/.publicApi/net6.0/PublicAPI.Unshipped.txt deleted file mode 100644 index 4669de906b..0000000000 --- a/src/OpenTelemetry.ResourceDetectors.Gcp/.publicApi/net6.0/PublicAPI.Unshipped.txt +++ /dev/null @@ -1,5 +0,0 @@ -OpenTelemetry.ResourceDetectors.Gcp.GcpResourceDetector -OpenTelemetry.ResourceDetectors.Gcp.GcpResourceDetector.GcpResourceDetector() -> void -OpenTelemetry.ResourceDetectors.Gcp.GcpResourceDetector.Detect() -> OpenTelemetry.Resources.Resource! -OpenTelemetry.Resources.GcpResourceBuilderExtensions -static OpenTelemetry.Resources.GcpResourceBuilderExtensions.AddGcpDetector(this OpenTelemetry.Resources.ResourceBuilder! builder) -> OpenTelemetry.Resources.ResourceBuilder! diff --git a/src/OpenTelemetry.ResourceDetectors.Gcp/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt b/src/OpenTelemetry.ResourceDetectors.Gcp/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt deleted file mode 100644 index 4669de906b..0000000000 --- a/src/OpenTelemetry.ResourceDetectors.Gcp/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt +++ /dev/null @@ -1,5 +0,0 @@ -OpenTelemetry.ResourceDetectors.Gcp.GcpResourceDetector -OpenTelemetry.ResourceDetectors.Gcp.GcpResourceDetector.GcpResourceDetector() -> void -OpenTelemetry.ResourceDetectors.Gcp.GcpResourceDetector.Detect() -> OpenTelemetry.Resources.Resource! -OpenTelemetry.Resources.GcpResourceBuilderExtensions -static OpenTelemetry.Resources.GcpResourceBuilderExtensions.AddGcpDetector(this OpenTelemetry.Resources.ResourceBuilder! builder) -> OpenTelemetry.Resources.ResourceBuilder! diff --git a/src/OpenTelemetry.ResourceDetectors.Gcp/AssemblyInfo.cs b/src/OpenTelemetry.ResourceDetectors.Gcp/AssemblyInfo.cs deleted file mode 100644 index 4b2346eec8..0000000000 --- a/src/OpenTelemetry.ResourceDetectors.Gcp/AssemblyInfo.cs +++ /dev/null @@ -1,10 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -using System.Runtime.CompilerServices; - -#if SIGNED -[assembly: InternalsVisibleTo("OpenTelemetry.ResourceDetectors.Gcp.Tests, PublicKey=002400000480000094000000060200000024000052534131000400000100010051c1562a090fb0c9f391012a32198b5e5d9a60e9b80fa2d7b434c9e5ccb7259bd606e66f9660676afc6692b8cdc6793d190904551d2103b7b22fa636dcbb8208839785ba402ea08fc00c8f1500ccef28bbf599aa64ffb1e1d5dc1bf3420a3777badfe697856e9d52070a50c3ea5821c80bef17ca3acffa28f89dd413f096f898")] -#else -[assembly: InternalsVisibleTo("OpenTelemetry.ResourceDetectors.Gcp.Tests")] -#endif diff --git a/src/OpenTelemetry.ResourceDetectors.Gcp/.publicApi/net6.0/PublicAPI.Shipped.txt b/src/OpenTelemetry.Resources.Gcp/.publicApi/net6.0/PublicAPI.Shipped.txt similarity index 100% rename from src/OpenTelemetry.ResourceDetectors.Gcp/.publicApi/net6.0/PublicAPI.Shipped.txt rename to src/OpenTelemetry.Resources.Gcp/.publicApi/net6.0/PublicAPI.Shipped.txt diff --git a/src/OpenTelemetry.Resources.Gcp/.publicApi/net6.0/PublicAPI.Unshipped.txt b/src/OpenTelemetry.Resources.Gcp/.publicApi/net6.0/PublicAPI.Unshipped.txt new file mode 100644 index 0000000000..183ca6301d --- /dev/null +++ b/src/OpenTelemetry.Resources.Gcp/.publicApi/net6.0/PublicAPI.Unshipped.txt @@ -0,0 +1,5 @@ +OpenTelemetry.Resources.Gcp.GcpResourceDetector +OpenTelemetry.Resources.Gcp.GcpResourceDetector.GcpResourceDetector() -> void +OpenTelemetry.Resources.Gcp.GcpResourceDetector.Detect() -> OpenTelemetry.Resources.Resource! +OpenTelemetry.Resources.GcpResourceBuilderExtensions +static OpenTelemetry.Resources.GcpResourceBuilderExtensions.AddGcpDetector(this OpenTelemetry.Resources.ResourceBuilder! builder) -> OpenTelemetry.Resources.ResourceBuilder! diff --git a/src/OpenTelemetry.ResourceDetectors.Gcp/.publicApi/netstandard2.0/PublicAPI.Shipped.txt b/src/OpenTelemetry.Resources.Gcp/.publicApi/netstandard2.0/PublicAPI.Shipped.txt similarity index 100% rename from src/OpenTelemetry.ResourceDetectors.Gcp/.publicApi/netstandard2.0/PublicAPI.Shipped.txt rename to src/OpenTelemetry.Resources.Gcp/.publicApi/netstandard2.0/PublicAPI.Shipped.txt diff --git a/src/OpenTelemetry.Resources.Gcp/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt b/src/OpenTelemetry.Resources.Gcp/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt new file mode 100644 index 0000000000..183ca6301d --- /dev/null +++ b/src/OpenTelemetry.Resources.Gcp/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt @@ -0,0 +1,5 @@ +OpenTelemetry.Resources.Gcp.GcpResourceDetector +OpenTelemetry.Resources.Gcp.GcpResourceDetector.GcpResourceDetector() -> void +OpenTelemetry.Resources.Gcp.GcpResourceDetector.Detect() -> OpenTelemetry.Resources.Resource! +OpenTelemetry.Resources.GcpResourceBuilderExtensions +static OpenTelemetry.Resources.GcpResourceBuilderExtensions.AddGcpDetector(this OpenTelemetry.Resources.ResourceBuilder! builder) -> OpenTelemetry.Resources.ResourceBuilder! diff --git a/src/OpenTelemetry.Resources.Gcp/AssemblyInfo.cs b/src/OpenTelemetry.Resources.Gcp/AssemblyInfo.cs new file mode 100644 index 0000000000..0751701190 --- /dev/null +++ b/src/OpenTelemetry.Resources.Gcp/AssemblyInfo.cs @@ -0,0 +1,10 @@ +// Copyright The OpenTelemetry Authors +// SPDX-License-Identifier: Apache-2.0 + +using System.Runtime.CompilerServices; + +#if SIGNED +[assembly: InternalsVisibleTo("OpenTelemetry.Resources.Gcp.Tests, PublicKey=002400000480000094000000060200000024000052534131000400000100010051c1562a090fb0c9f391012a32198b5e5d9a60e9b80fa2d7b434c9e5ccb7259bd606e66f9660676afc6692b8cdc6793d190904551d2103b7b22fa636dcbb8208839785ba402ea08fc00c8f1500ccef28bbf599aa64ffb1e1d5dc1bf3420a3777badfe697856e9d52070a50c3ea5821c80bef17ca3acffa28f89dd413f096f898")] +#else +[assembly: InternalsVisibleTo("OpenTelemetry.Resources.Gcp.Tests")] +#endif diff --git a/src/OpenTelemetry.ResourceDetectors.Gcp/CHANGELOG.md b/src/OpenTelemetry.Resources.Gcp/CHANGELOG.md similarity index 100% rename from src/OpenTelemetry.ResourceDetectors.Gcp/CHANGELOG.md rename to src/OpenTelemetry.Resources.Gcp/CHANGELOG.md diff --git a/src/OpenTelemetry.ResourceDetectors.Gcp/GcpResourceBuilderExtensions.cs b/src/OpenTelemetry.Resources.Gcp/GcpResourceBuilderExtensions.cs similarity index 94% rename from src/OpenTelemetry.ResourceDetectors.Gcp/GcpResourceBuilderExtensions.cs rename to src/OpenTelemetry.Resources.Gcp/GcpResourceBuilderExtensions.cs index 9a04495c76..154242bb04 100644 --- a/src/OpenTelemetry.ResourceDetectors.Gcp/GcpResourceBuilderExtensions.cs +++ b/src/OpenTelemetry.Resources.Gcp/GcpResourceBuilderExtensions.cs @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 using OpenTelemetry.Internal; -using OpenTelemetry.ResourceDetectors.Gcp; +using OpenTelemetry.Resources.Gcp; namespace OpenTelemetry.Resources; diff --git a/src/OpenTelemetry.ResourceDetectors.Gcp/GcpResourceDetector.cs b/src/OpenTelemetry.Resources.Gcp/GcpResourceDetector.cs similarity index 98% rename from src/OpenTelemetry.ResourceDetectors.Gcp/GcpResourceDetector.cs rename to src/OpenTelemetry.Resources.Gcp/GcpResourceDetector.cs index b0d9043eb0..4451885d02 100644 --- a/src/OpenTelemetry.ResourceDetectors.Gcp/GcpResourceDetector.cs +++ b/src/OpenTelemetry.Resources.Gcp/GcpResourceDetector.cs @@ -6,7 +6,7 @@ using OpenTelemetry.Resources; using OpenTelemetry.Trace; -namespace OpenTelemetry.ResourceDetectors.Gcp; +namespace OpenTelemetry.Resources.Gcp; /// /// Resource detector for Google Cloud Platform (GCP). diff --git a/src/OpenTelemetry.ResourceDetectors.Gcp/OpenTelemetry.ResourceDetectors.Gcp.csproj b/src/OpenTelemetry.Resources.Gcp/OpenTelemetry.Resources.Gcp.csproj similarity index 93% rename from src/OpenTelemetry.ResourceDetectors.Gcp/OpenTelemetry.ResourceDetectors.Gcp.csproj rename to src/OpenTelemetry.Resources.Gcp/OpenTelemetry.Resources.Gcp.csproj index 3ce1507c0d..54dd10ff42 100644 --- a/src/OpenTelemetry.ResourceDetectors.Gcp/OpenTelemetry.ResourceDetectors.Gcp.csproj +++ b/src/OpenTelemetry.Resources.Gcp/OpenTelemetry.Resources.Gcp.csproj @@ -3,7 +3,7 @@ net6.0;netstandard2.0 OpenTelemetry Resource Detectors for Google Cloud Platform environments $(PackageTags);ResourceDetector - ResourceDetectors.GCP- + Resources.Gcp- diff --git a/src/OpenTelemetry.ResourceDetectors.Gcp/README.md b/src/OpenTelemetry.Resources.Gcp/README.md similarity index 93% rename from src/OpenTelemetry.ResourceDetectors.Gcp/README.md rename to src/OpenTelemetry.Resources.Gcp/README.md index 0b100dbd67..e2438ad65c 100644 --- a/src/OpenTelemetry.ResourceDetectors.Gcp/README.md +++ b/src/OpenTelemetry.Resources.Gcp/README.md @@ -1,6 +1,6 @@ # Resource Detectors for Google Cloud Platform environments -[![NuGet version badge](https://img.shields.io/nuget/v/OpenTelemetry.ResourceDetectors.Gcp)](https://www.nuget.org/packages/OpenTelemetry.ResourceDetectors.Gcp) +[![NuGet version badge](https://img.shields.io/nuget/v/OpenTelemetry.Resources.Gcp)](https://www.nuget.org/packages/OpenTelemetry.Resources.Gcp) [![NuGet download count badge](https://img.shields.io/nuget/dt/OpenTelemetry.ResourceDetectors.Azure)](https://www.nuget.org/packages/OpenTelemetry.ResourceDetectors.Azure) This package contains [Resource @@ -10,7 +10,7 @@ for applications running in Google Cloud Platform environments. ## Installation ```shell -dotnet add package --prerelease OpenTelemetry.ResourceDetectors.Gcp +dotnet add package --prerelease OpenTelemetry.Resources.Gcp ``` ```csharp diff --git a/src/OpenTelemetry.ResourceDetectors.Gcp/ResourceAttributeConstants.cs b/src/OpenTelemetry.Resources.Gcp/ResourceAttributeConstants.cs similarity index 91% rename from src/OpenTelemetry.ResourceDetectors.Gcp/ResourceAttributeConstants.cs rename to src/OpenTelemetry.Resources.Gcp/ResourceAttributeConstants.cs index 00e9f46ec5..6c9a0b8c36 100644 --- a/src/OpenTelemetry.ResourceDetectors.Gcp/ResourceAttributeConstants.cs +++ b/src/OpenTelemetry.Resources.Gcp/ResourceAttributeConstants.cs @@ -1,7 +1,7 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 -namespace OpenTelemetry.ResourceDetectors.Gcp; +namespace OpenTelemetry.Resources.Gcp; internal sealed class ResourceAttributeConstants { diff --git a/test/OpenTelemetry.ResourceDetectors.Gcp.Tests/GcpResourceDetectorTests.cs b/test/OpenTelemetry.Resources.Gcp.Tests/GcpResourceDetectorTests.cs similarity index 98% rename from test/OpenTelemetry.ResourceDetectors.Gcp.Tests/GcpResourceDetectorTests.cs rename to test/OpenTelemetry.Resources.Gcp.Tests/GcpResourceDetectorTests.cs index e34c436adc..6369d7fda2 100644 --- a/test/OpenTelemetry.ResourceDetectors.Gcp.Tests/GcpResourceDetectorTests.cs +++ b/test/OpenTelemetry.Resources.Gcp.Tests/GcpResourceDetectorTests.cs @@ -5,7 +5,7 @@ using Google.Api.Gax; using OpenTelemetry.Trace; -namespace OpenTelemetry.ResourceDetectors.Gcp.Tests; +namespace OpenTelemetry.Resources.Gcp.Tests; public class GcpResourceDetectorTests { diff --git a/test/OpenTelemetry.ResourceDetectors.Gcp.Tests/GlobalUsings.cs b/test/OpenTelemetry.Resources.Gcp.Tests/GlobalUsings.cs similarity index 100% rename from test/OpenTelemetry.ResourceDetectors.Gcp.Tests/GlobalUsings.cs rename to test/OpenTelemetry.Resources.Gcp.Tests/GlobalUsings.cs diff --git a/test/OpenTelemetry.ResourceDetectors.Gcp.Tests/OpenTelemetry.ResourceDetectors.Gcp.Tests.csproj b/test/OpenTelemetry.Resources.Gcp.Tests/OpenTelemetry.Resources.Gcp.Tests.csproj similarity index 91% rename from test/OpenTelemetry.ResourceDetectors.Gcp.Tests/OpenTelemetry.ResourceDetectors.Gcp.Tests.csproj rename to test/OpenTelemetry.Resources.Gcp.Tests/OpenTelemetry.Resources.Gcp.Tests.csproj index afbf8bef31..e1df281415 100644 --- a/test/OpenTelemetry.ResourceDetectors.Gcp.Tests/OpenTelemetry.ResourceDetectors.Gcp.Tests.csproj +++ b/test/OpenTelemetry.Resources.Gcp.Tests/OpenTelemetry.Resources.Gcp.Tests.csproj @@ -12,7 +12,7 @@ - + From abbcb0eba2bb140d8395496628a655a592bfcbd4 Mon Sep 17 00:00:00 2001 From: Matthew Hensley Date: Wed, 1 May 2024 13:15:56 -0400 Subject: [PATCH 18/33] missed file when renaming --- ...esourceDetectors.Gcp.proj => OpenTelemetry.Resources.Gcp.proj} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename build/Projects/{OpenTelemetry.ResourceDetectors.Gcp.proj => OpenTelemetry.Resources.Gcp.proj} (100%) diff --git a/build/Projects/OpenTelemetry.ResourceDetectors.Gcp.proj b/build/Projects/OpenTelemetry.Resources.Gcp.proj similarity index 100% rename from build/Projects/OpenTelemetry.ResourceDetectors.Gcp.proj rename to build/Projects/OpenTelemetry.Resources.Gcp.proj From 90ede06df88a4663c84f75e7b04f1d8df8506245 Mon Sep 17 00:00:00 2001 From: Matthew Hensley Date: Wed, 1 May 2024 13:16:03 -0400 Subject: [PATCH 19/33] linter error --- src/OpenTelemetry.Resources.Gcp/GcpResourceDetector.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/OpenTelemetry.Resources.Gcp/GcpResourceDetector.cs b/src/OpenTelemetry.Resources.Gcp/GcpResourceDetector.cs index 4451885d02..109f0967ce 100644 --- a/src/OpenTelemetry.Resources.Gcp/GcpResourceDetector.cs +++ b/src/OpenTelemetry.Resources.Gcp/GcpResourceDetector.cs @@ -3,7 +3,6 @@ using System.Collections.Generic; using Google.Api.Gax; -using OpenTelemetry.Resources; using OpenTelemetry.Trace; namespace OpenTelemetry.Resources.Gcp; From f0e54f1884cf84690c791b77011d2a982f009269 Mon Sep 17 00:00:00 2001 From: Matthew Hensley Date: Wed, 1 May 2024 13:21:01 -0400 Subject: [PATCH 20/33] another missed name --- .github/codecov.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/codecov.yml b/.github/codecov.yml index 6ae6cc15c3..4db58f86c0 100644 --- a/.github/codecov.yml +++ b/.github/codecov.yml @@ -109,7 +109,7 @@ flags: paths: - src/OpenTelemetry.ResourceDetectors.Azure - unittests-ResourceDetectors.Gcp: + unittests-Resources.Gcp: carryforward: true paths: - src/OpenTelemetry.Resources.Gcp From f32e81f511fd05ad3c4538f2f5feaceb43009a80 Mon Sep 17 00:00:00 2001 From: Matthew Hensley Date: Wed, 1 May 2024 13:24:49 -0400 Subject: [PATCH 21/33] improve CHANGELOG --- src/OpenTelemetry.Resources.Gcp/CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/OpenTelemetry.Resources.Gcp/CHANGELOG.md b/src/OpenTelemetry.Resources.Gcp/CHANGELOG.md index e83c4c50bc..be192a744c 100644 --- a/src/OpenTelemetry.Resources.Gcp/CHANGELOG.md +++ b/src/OpenTelemetry.Resources.Gcp/CHANGELOG.md @@ -2,7 +2,8 @@ ## Unreleased -* Add Google Cloud Platform resource detector for GKE, GAE, GCR, and GCE. +* Add Google Cloud Platform resource detector for GKE, GAE, GCR, and GCE. Dectector +is accessible via `AddGcpDetector` extension method on `ResourceBuilder`. ([#1691](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/1691)) For more details, please refer to the [README](README.md). From 2b8f97ee7683681185f21add89e9cd360365ae1e Mon Sep 17 00:00:00 2001 From: Matthew Hensley Date: Wed, 1 May 2024 15:39:58 -0400 Subject: [PATCH 22/33] add meter and log resource examples --- src/OpenTelemetry.Resources.Gcp/README.md | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/OpenTelemetry.Resources.Gcp/README.md b/src/OpenTelemetry.Resources.Gcp/README.md index e2438ad65c..3171fa579c 100644 --- a/src/OpenTelemetry.Resources.Gcp/README.md +++ b/src/OpenTelemetry.Resources.Gcp/README.md @@ -17,10 +17,25 @@ dotnet add package --prerelease OpenTelemetry.Resources.Gcp using OpenTelemetry; using OpenTelemetry.Resources; -var tracerProvider = Sdk.CreateTracerProviderBuilder() +using var meterProvider = Sdk.CreateMeterProviderBuilder() // other configurations .ConfigureResource(resource => resource.AddGcpDetector()) .Build(); + +using var tracerProvider = Sdk.CreateTracerProviderBuilder() + // other configurations + .ConfigureResource(resource => resource.AddGcpDetector()) + .Build(); + +using var loggerFactory = LoggerFactory.Create(builder => +{ + builder.AddOpenTelemetry(options => + { + options.SetResourceBuilder(ResourceBuilder + .CreateDefault() + .AddGcpDetector()); + }); +}); ``` ## Resource Attributes From c456ce35aab61f9e6ed4a764773e4e5862789e82 Mon Sep 17 00:00:00 2001 From: Matthew Hensley Date: Thu, 2 May 2024 08:32:42 -0400 Subject: [PATCH 23/33] mark as codeowner --- .github/component_owners.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/component_owners.yml b/.github/component_owners.yml index 73aba2c284..4ebcf7ea14 100644 --- a/.github/component_owners.yml +++ b/.github/component_owners.yml @@ -79,6 +79,8 @@ components: src/OpenTelemetry.ResourceDetectors.ProcessRuntime/: - Kielek - lachmatt + src/OpenTelemetry.Resources.Gcp/: + - matt-hensley src/OpenTelemetry.Sampler.AWS/: - srprash - atshaw43 From 827271f953f3bddb477d2c0e2978279e856bd746 Mon Sep 17 00:00:00 2001 From: Matthew Hensley Date: Thu, 2 May 2024 19:21:24 -0400 Subject: [PATCH 24/33] rename --- ...ackage-ResourceDetectors.Gcp.yml => package-Resources.Gcp.yml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{package-ResourceDetectors.Gcp.yml => package-Resources.Gcp.yml} (100%) diff --git a/.github/workflows/package-ResourceDetectors.Gcp.yml b/.github/workflows/package-Resources.Gcp.yml similarity index 100% rename from .github/workflows/package-ResourceDetectors.Gcp.yml rename to .github/workflows/package-Resources.Gcp.yml From c6621b23d10319c40abb8c8f5c65e4ba59f23839 Mon Sep 17 00:00:00 2001 From: Matthew Hensley Date: Thu, 2 May 2024 19:24:48 -0400 Subject: [PATCH 25/33] remove used package --- .../OpenTelemetry.Resources.Gcp.csproj | 1 - 1 file changed, 1 deletion(-) diff --git a/src/OpenTelemetry.Resources.Gcp/OpenTelemetry.Resources.Gcp.csproj b/src/OpenTelemetry.Resources.Gcp/OpenTelemetry.Resources.Gcp.csproj index 54dd10ff42..cb4de6eb15 100644 --- a/src/OpenTelemetry.Resources.Gcp/OpenTelemetry.Resources.Gcp.csproj +++ b/src/OpenTelemetry.Resources.Gcp/OpenTelemetry.Resources.Gcp.csproj @@ -8,7 +8,6 @@ - From 9b0b80daccef390b701b5ea9445caca2986e273c Mon Sep 17 00:00:00 2001 From: Matthew Hensley Date: Thu, 2 May 2024 19:28:38 -0400 Subject: [PATCH 26/33] mark detector internal, remove from API --- .../.publicApi/net6.0/PublicAPI.Unshipped.txt | 3 --- .../.publicApi/netstandard2.0/PublicAPI.Unshipped.txt | 3 --- src/OpenTelemetry.Resources.Gcp/GcpResourceDetector.cs | 2 +- 3 files changed, 1 insertion(+), 7 deletions(-) diff --git a/src/OpenTelemetry.Resources.Gcp/.publicApi/net6.0/PublicAPI.Unshipped.txt b/src/OpenTelemetry.Resources.Gcp/.publicApi/net6.0/PublicAPI.Unshipped.txt index 183ca6301d..2cd50017d2 100644 --- a/src/OpenTelemetry.Resources.Gcp/.publicApi/net6.0/PublicAPI.Unshipped.txt +++ b/src/OpenTelemetry.Resources.Gcp/.publicApi/net6.0/PublicAPI.Unshipped.txt @@ -1,5 +1,2 @@ -OpenTelemetry.Resources.Gcp.GcpResourceDetector -OpenTelemetry.Resources.Gcp.GcpResourceDetector.GcpResourceDetector() -> void -OpenTelemetry.Resources.Gcp.GcpResourceDetector.Detect() -> OpenTelemetry.Resources.Resource! OpenTelemetry.Resources.GcpResourceBuilderExtensions static OpenTelemetry.Resources.GcpResourceBuilderExtensions.AddGcpDetector(this OpenTelemetry.Resources.ResourceBuilder! builder) -> OpenTelemetry.Resources.ResourceBuilder! diff --git a/src/OpenTelemetry.Resources.Gcp/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt b/src/OpenTelemetry.Resources.Gcp/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt index 183ca6301d..2cd50017d2 100644 --- a/src/OpenTelemetry.Resources.Gcp/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt +++ b/src/OpenTelemetry.Resources.Gcp/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt @@ -1,5 +1,2 @@ -OpenTelemetry.Resources.Gcp.GcpResourceDetector -OpenTelemetry.Resources.Gcp.GcpResourceDetector.GcpResourceDetector() -> void -OpenTelemetry.Resources.Gcp.GcpResourceDetector.Detect() -> OpenTelemetry.Resources.Resource! OpenTelemetry.Resources.GcpResourceBuilderExtensions static OpenTelemetry.Resources.GcpResourceBuilderExtensions.AddGcpDetector(this OpenTelemetry.Resources.ResourceBuilder! builder) -> OpenTelemetry.Resources.ResourceBuilder! diff --git a/src/OpenTelemetry.Resources.Gcp/GcpResourceDetector.cs b/src/OpenTelemetry.Resources.Gcp/GcpResourceDetector.cs index 109f0967ce..de5d212484 100644 --- a/src/OpenTelemetry.Resources.Gcp/GcpResourceDetector.cs +++ b/src/OpenTelemetry.Resources.Gcp/GcpResourceDetector.cs @@ -10,7 +10,7 @@ namespace OpenTelemetry.Resources.Gcp; /// /// Resource detector for Google Cloud Platform (GCP). /// -public sealed class GcpResourceDetector : IResourceDetector +internal sealed class GcpResourceDetector : IResourceDetector { /// public Resource Detect() From d226d877c2b2d91c921ffe82bca99f7a1f638527 Mon Sep 17 00:00:00 2001 From: Matthew Hensley Date: Mon, 6 May 2024 10:33:55 -0400 Subject: [PATCH 27/33] add issue template --- .github/ISSUE_TEMPLATE/comp_resources_gcp.md | 41 ++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/comp_resources_gcp.md diff --git a/.github/ISSUE_TEMPLATE/comp_resources_gcp.md b/.github/ISSUE_TEMPLATE/comp_resources_gcp.md new file mode 100644 index 0000000000..3691f925fb --- /dev/null +++ b/.github/ISSUE_TEMPLATE/comp_resources_gcp.md @@ -0,0 +1,41 @@ +--- +name: OpenTelemetry.Resources.Gcp +about: OpenTelemetry.Resources.Gcp +labels: comp:resources.gcp +--- + +# Issue with OpenTelemetry.Resources.Gcp + +List of [all OpenTelemetry NuGet +packages](https://www.nuget.org/profiles/OpenTelemetry) and version that you are +using (e.g. `OpenTelemetry 1.3.2`): + +* TBD + +Runtime version (e.g. `net462`, `net48`, `net6.0`, `net7.0` etc. You can +find this information from the `*.csproj` file): + +* TBD + +**Is this a feature request or a bug?** + +* [ ] Feature Request +* [ ] Bug + +**What is the expected behavior?** + +What do you expect to see? + +**What is the actual behavior?** + +What did you see instead? If you are reporting a bug, create a self-contained +project using the template of your choice and apply the minimum required code to +result in the issue you're observing. We will close this issue if: + +* The repro project you share with us is complex. We can't investigate custom + projects, so don't point us to such, please. +* If we can not reproduce the behavior you're reporting. + +## Additional Context + +Add any other context about the feature request here. From 59441be4e83f83d966786f1c4b5e5900f855d7ab Mon Sep 17 00:00:00 2001 From: Matthew Hensley Date: Mon, 6 May 2024 10:34:07 -0400 Subject: [PATCH 28/33] test component owner --- .github/component_owners.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/component_owners.yml b/.github/component_owners.yml index 4ebcf7ea14..53dcb8683a 100644 --- a/.github/component_owners.yml +++ b/.github/component_owners.yml @@ -171,6 +171,8 @@ components: test/OpenTelemetry.ResourceDetectors.ProcessRuntime.Tests/: - Kielek - lachmatt + test/OpenTelemetry.Resources.Gcp.Tests/: + - matt-hensley test/OpenTelemetry.Sampler.AWS.Tests/: - srprash - atshaw43 From 5b945dac853c68e0bccdb4b0ea4c4acdce6b661b Mon Sep 17 00:00:00 2001 From: Matt Hensley <130569+matt-hensley@users.noreply.github.com> Date: Mon, 6 May 2024 10:34:47 -0400 Subject: [PATCH 29/33] Update src/OpenTelemetry.Resources.Gcp/CHANGELOG.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Piotr Kiełkowicz --- src/OpenTelemetry.Resources.Gcp/CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/OpenTelemetry.Resources.Gcp/CHANGELOG.md b/src/OpenTelemetry.Resources.Gcp/CHANGELOG.md index be192a744c..e1852ed3a7 100644 --- a/src/OpenTelemetry.Resources.Gcp/CHANGELOG.md +++ b/src/OpenTelemetry.Resources.Gcp/CHANGELOG.md @@ -3,7 +3,7 @@ ## Unreleased * Add Google Cloud Platform resource detector for GKE, GAE, GCR, and GCE. Dectector -is accessible via `AddGcpDetector` extension method on `ResourceBuilder`. - ([#1691](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/1691)) + is accessible via `AddGcpDetector` extension method on `ResourceBuilder`. + ([#1691](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/1691)) For more details, please refer to the [README](README.md). From 947a7a87744c4b8497b08bd2c37c170cc3fe76b4 Mon Sep 17 00:00:00 2001 From: Matthew Hensley Date: Wed, 8 May 2024 09:13:46 -0400 Subject: [PATCH 30/33] add second owner --- .github/component_owners.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/component_owners.yml b/.github/component_owners.yml index 53dcb8683a..7df093a797 100644 --- a/.github/component_owners.yml +++ b/.github/component_owners.yml @@ -81,6 +81,7 @@ components: - lachmatt src/OpenTelemetry.Resources.Gcp/: - matt-hensley + - pyohannes src/OpenTelemetry.Sampler.AWS/: - srprash - atshaw43 @@ -173,6 +174,7 @@ components: - lachmatt test/OpenTelemetry.Resources.Gcp.Tests/: - matt-hensley + - pyohannes test/OpenTelemetry.Sampler.AWS.Tests/: - srprash - atshaw43 From 3bc5fe6088c2bac03c0212db239485b919357247 Mon Sep 17 00:00:00 2001 From: Matthew Hensley Date: Fri, 10 May 2024 16:55:57 -0400 Subject: [PATCH 31/33] unify public api specs --- .../.publicApi/{net6.0 => }/PublicAPI.Shipped.txt | 0 .../.publicApi/{net6.0 => }/PublicAPI.Unshipped.txt | 0 .../.publicApi/netstandard2.0/PublicAPI.Shipped.txt | 1 - .../.publicApi/netstandard2.0/PublicAPI.Unshipped.txt | 2 -- 4 files changed, 3 deletions(-) rename src/OpenTelemetry.Resources.Gcp/.publicApi/{net6.0 => }/PublicAPI.Shipped.txt (100%) rename src/OpenTelemetry.Resources.Gcp/.publicApi/{net6.0 => }/PublicAPI.Unshipped.txt (100%) delete mode 100644 src/OpenTelemetry.Resources.Gcp/.publicApi/netstandard2.0/PublicAPI.Shipped.txt delete mode 100644 src/OpenTelemetry.Resources.Gcp/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt diff --git a/src/OpenTelemetry.Resources.Gcp/.publicApi/net6.0/PublicAPI.Shipped.txt b/src/OpenTelemetry.Resources.Gcp/.publicApi/PublicAPI.Shipped.txt similarity index 100% rename from src/OpenTelemetry.Resources.Gcp/.publicApi/net6.0/PublicAPI.Shipped.txt rename to src/OpenTelemetry.Resources.Gcp/.publicApi/PublicAPI.Shipped.txt diff --git a/src/OpenTelemetry.Resources.Gcp/.publicApi/net6.0/PublicAPI.Unshipped.txt b/src/OpenTelemetry.Resources.Gcp/.publicApi/PublicAPI.Unshipped.txt similarity index 100% rename from src/OpenTelemetry.Resources.Gcp/.publicApi/net6.0/PublicAPI.Unshipped.txt rename to src/OpenTelemetry.Resources.Gcp/.publicApi/PublicAPI.Unshipped.txt diff --git a/src/OpenTelemetry.Resources.Gcp/.publicApi/netstandard2.0/PublicAPI.Shipped.txt b/src/OpenTelemetry.Resources.Gcp/.publicApi/netstandard2.0/PublicAPI.Shipped.txt deleted file mode 100644 index 7dc5c58110..0000000000 --- a/src/OpenTelemetry.Resources.Gcp/.publicApi/netstandard2.0/PublicAPI.Shipped.txt +++ /dev/null @@ -1 +0,0 @@ -#nullable enable diff --git a/src/OpenTelemetry.Resources.Gcp/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt b/src/OpenTelemetry.Resources.Gcp/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt deleted file mode 100644 index 2cd50017d2..0000000000 --- a/src/OpenTelemetry.Resources.Gcp/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt +++ /dev/null @@ -1,2 +0,0 @@ -OpenTelemetry.Resources.GcpResourceBuilderExtensions -static OpenTelemetry.Resources.GcpResourceBuilderExtensions.AddGcpDetector(this OpenTelemetry.Resources.ResourceBuilder! builder) -> OpenTelemetry.Resources.ResourceBuilder! From e54df3234e2b45aafccd661fd01ee8fa429698c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Kie=C5=82kowicz?= Date: Mon, 13 May 2024 07:30:36 +0200 Subject: [PATCH 32/33] Handles changes on main --- .github/ISSUE_TEMPLATE/bug_report.yml | 1 + .github/ISSUE_TEMPLATE/comp_resources_gcp.md | 41 -------------------- .github/ISSUE_TEMPLATE/feature_request.yml | 1 + 3 files changed, 2 insertions(+), 41 deletions(-) delete mode 100644 .github/ISSUE_TEMPLATE/comp_resources_gcp.md diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index 8b9c393599..03db52b3c9 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -54,6 +54,7 @@ body: - OpenTelemetry.ResourceDetectors.Host - OpenTelemetry.ResourceDetectors.Process - OpenTelemetry.ResourceDetectors.ProcessRuntime + - OpenTelemetry.Resources.Gcp - OpenTelemetry.Sampler.AWS - OpenTelemetry.SemanticConventions validations: diff --git a/.github/ISSUE_TEMPLATE/comp_resources_gcp.md b/.github/ISSUE_TEMPLATE/comp_resources_gcp.md deleted file mode 100644 index 3691f925fb..0000000000 --- a/.github/ISSUE_TEMPLATE/comp_resources_gcp.md +++ /dev/null @@ -1,41 +0,0 @@ ---- -name: OpenTelemetry.Resources.Gcp -about: OpenTelemetry.Resources.Gcp -labels: comp:resources.gcp ---- - -# Issue with OpenTelemetry.Resources.Gcp - -List of [all OpenTelemetry NuGet -packages](https://www.nuget.org/profiles/OpenTelemetry) and version that you are -using (e.g. `OpenTelemetry 1.3.2`): - -* TBD - -Runtime version (e.g. `net462`, `net48`, `net6.0`, `net7.0` etc. You can -find this information from the `*.csproj` file): - -* TBD - -**Is this a feature request or a bug?** - -* [ ] Feature Request -* [ ] Bug - -**What is the expected behavior?** - -What do you expect to see? - -**What is the actual behavior?** - -What did you see instead? If you are reporting a bug, create a self-contained -project using the template of your choice and apply the minimum required code to -result in the issue you're observing. We will close this issue if: - -* The repro project you share with us is complex. We can't investigate custom - projects, so don't point us to such, please. -* If we can not reproduce the behavior you're reporting. - -## Additional Context - -Add any other context about the feature request here. diff --git a/.github/ISSUE_TEMPLATE/feature_request.yml b/.github/ISSUE_TEMPLATE/feature_request.yml index 9fecb78998..2d8c7483d7 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.yml +++ b/.github/ISSUE_TEMPLATE/feature_request.yml @@ -54,6 +54,7 @@ body: - OpenTelemetry.ResourceDetectors.Host - OpenTelemetry.ResourceDetectors.Process - OpenTelemetry.ResourceDetectors.ProcessRuntime + - OpenTelemetry.Resources.Gcp - OpenTelemetry.Sampler.AWS - OpenTelemetry.SemanticConventions From 10027ddf7b902a6937ec2c398754227173a1c30d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Kie=C5=82kowicz?= Date: Mon, 13 May 2024 07:46:39 +0200 Subject: [PATCH 33/33] Handle changes from main - part 2 --- .../OpenTelemetry.Resources.Gcp.csproj | 36 +++++++++++-------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/src/OpenTelemetry.Resources.Gcp/OpenTelemetry.Resources.Gcp.csproj b/src/OpenTelemetry.Resources.Gcp/OpenTelemetry.Resources.Gcp.csproj index cb4de6eb15..e0b3c71433 100644 --- a/src/OpenTelemetry.Resources.Gcp/OpenTelemetry.Resources.Gcp.csproj +++ b/src/OpenTelemetry.Resources.Gcp/OpenTelemetry.Resources.Gcp.csproj @@ -1,19 +1,25 @@ - - net6.0;netstandard2.0 - OpenTelemetry Resource Detectors for Google Cloud Platform environments - $(PackageTags);ResourceDetector - Resources.Gcp- - + + net6.0;netstandard2.0 + OpenTelemetry Resource Detectors for Google Cloud Platform environments + $(PackageTags);ResourceDetector + Resources.Gcp- + - - - - - + + + true + - - - - + + + + + + + + + +