Skip to content

Commit

Permalink
[Resources.Container] Rename Container detector namespace (#1849)
Browse files Browse the repository at this point in the history
Co-authored-by: joegoldman2 <147369450+joegoldman@users.noreply.github.com>
Co-authored-by: Piotr Kiełkowicz <pkiekowicz@splunk.com>
  • Loading branch information
3 people committed Jun 4, 2024
1 parent a2683bf commit 4107ce2
Show file tree
Hide file tree
Showing 23 changed files with 114 additions and 82 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ body:
- OpenTelemetry.Instrumentation.Wcf
- OpenTelemetry.PersistentStorage.Abstractions
- OpenTelemetry.PersistentStorage.FileSystem
- OpenTelemetry.ResourceDetectors.Container
- OpenTelemetry.Resources.AWS
- OpenTelemetry.Resources.Azure
- OpenTelemetry.Resources.Container
- OpenTelemetry.Resources.Gcp
- OpenTelemetry.Resources.Host
- OpenTelemetry.Resources.Process
Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/feature_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ body:
- OpenTelemetry.Instrumentation.Wcf
- OpenTelemetry.PersistentStorage.Abstractions
- OpenTelemetry.PersistentStorage.FileSystem
- OpenTelemetry.ResourceDetectors.Container
- OpenTelemetry.Resources.AWS
- OpenTelemetry.Resources.Azure
- OpenTelemetry.Resources.Container
- OpenTelemetry.Resources.Gcp
- OpenTelemetry.Resources.Host
- OpenTelemetry.Resources.Process
Expand Down
8 changes: 4 additions & 4 deletions .github/component_owners.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,14 @@ components:
- vishweshbankwar
src/OpenTelemetry.PersistentStorage.FileSystem/:
- vishweshbankwar
src/OpenTelemetry.ResourceDetectors.Container/:
- iskiselev
src/OpenTelemetry.Resources.AWS/:
- srprash
- ppittle
src/OpenTelemetry.Resources.Azure/:
- rajkumar-rangaraj
- vishweshbankwar
src/OpenTelemetry.Resources.Container/:
- iskiselev
src/OpenTelemetry.Resources.Host/:
- Kielek
- lachmatt
Expand Down Expand Up @@ -151,14 +151,14 @@ components:
- codeblanch
test/OpenTelemetry.PersistentStorage.FileSystem.Tests/:
- vishweshbankwar
test/OpenTelemetry.ResourceDetectors.Container.Tests/:
- iskiselev
test/OpenTelemetry.Resources.AWS.Tests/:
- srprash
- ppittle
test/OpenTelemetry.Resources.Azure.Tests/:
- rajkumar-rangaraj
- vishweshbankwar
test/OpenTelemetry.Resources.Container.Tests/:
- iskiselev
test/OpenTelemetry.Resources.Host.Tests/:
- Kielek
- lachmatt
Expand Down
28 changes: 14 additions & 14 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ jobs:
instrumentation-stackexchangeredis: ['*/OpenTelemetry.Instrumentation.StackExchangeRedis*/**', 'examples/redis/**', '!**/*.md']
instrumentation-wcf: ['*/OpenTelemetry.Instrumentation.Wcf*/**', 'examples/wcf/**', '!**/*.md']
persistentstorage: ['*/OpenTelemetry.PersistentStorage*/**', '!**/*.md']
resourcedetectors-container: ['*/OpenTelemetry.ResourceDetectors.Container*/**', '!**/*.md']
resources-aws: ['*/OpenTelemetry.Resources.AWS*/**', '!**/*.md']
resources-azure: ['*/OpenTelemetry.Resources.Azure*/**', '!**/*.md']
resources-container: ['*/OpenTelemetry.Resources.Container*/**', '!**/*.md']
resources-gcp: ['*/OpenTelemetry.Resources.Gcp*/**', '!**/*.md']
resources-host: ['*/OpenTelemetry.Resources.Host*/**', '!**/*.md']
resources-process: ['*/OpenTelemetry.Resources.Process/**', '*/OpenTelemetry.Resources.Process.Tests/**', '!**/*.md']
Expand Down Expand Up @@ -398,17 +398,6 @@ jobs:
project-name: OpenTelemetry.PersistentStorage
code-cov-name: PersistentStorage

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

build-test-resources-aws:
needs: detect-changes
if: |
Expand All @@ -431,6 +420,17 @@ jobs:
project-name: Component[OpenTelemetry.Resources.Azure]
code-cov-name: Resources.Azure

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

build-test-resources-gcp:
needs: detect-changes
if: |
Expand Down Expand Up @@ -524,9 +524,9 @@ jobs:
|| contains(needs.detect-changes.outputs.changes, 'instrumentation-runtime')
|| contains(needs.detect-changes.outputs.changes, 'instrumentation-sqlclient')
|| contains(needs.detect-changes.outputs.changes, 'instrumentation-stackexchangeredis')
|| contains(needs.detect-changes.outputs.changes, 'resourcedetectors-container')
|| contains(needs.detect-changes.outputs.changes, 'resources-aws')
|| contains(needs.detect-changes.outputs.changes, 'resources-azure')
|| contains(needs.detect-changes.outputs.changes, 'resources-container')
|| contains(needs.detect-changes.outputs.changes, 'resources-host')
|| contains(needs.detect-changes.outputs.changes, 'resources-process')
|| contains(needs.detect-changes.outputs.changes, 'resources-processruntime')
Expand Down Expand Up @@ -572,9 +572,9 @@ jobs:
build-test-instrumentation-stackexchangeredis-integration,
build-test-instrumentation-wcf,
build-test-persistentstorage,
build-test-resourcedetectors-container,
build-test-resources-aws,
build-test-resources-azure,
build-test-resources-container,
build-test-resources-gcp,
build-test-resources-host,
build-test-resources-process,
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/publish-packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ on:
- 'Extensions-*'
- 'Instrumentation.*-*'
- 'PersistentStorage-*'
- 'ResourceDetectors.*-*'
- 'Resources.*-*'
- 'Sampler.*-*'
- 'SemanticConventions-*'
Expand Down
4 changes: 2 additions & 2 deletions opentelemetry-dotnet-contrib.sln
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenTelemetry.Extensions",
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenTelemetry.Extensions.Tests", "test\OpenTelemetry.Extensions.Tests\OpenTelemetry.Extensions.Tests.csproj", "{2117F4E3-6612-4E4D-A757-27271EEB7783}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenTelemetry.ResourceDetectors.Container", "src\OpenTelemetry.ResourceDetectors.Container\OpenTelemetry.ResourceDetectors.Container.csproj", "{498A6808-C0DF-441F-A764-51A3BC4B8FC5}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenTelemetry.Resources.Container", "src\OpenTelemetry.Resources.Container\OpenTelemetry.Resources.Container.csproj", "{498A6808-C0DF-441F-A764-51A3BC4B8FC5}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenTelemetry.ResourceDetectors.Container.Tests", "test\OpenTelemetry.ResourceDetectors.Container.Tests\OpenTelemetry.ResourceDetectors.Container.Tests.csproj", "{FB41E19E-2682-4D07-BA59-FD5205AFA71E}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenTelemetry.Resources.Container.Tests", "test\OpenTelemetry.Resources.Container.Tests\OpenTelemetry.Resources.Container.Tests.csproj", "{FB41E19E-2682-4D07-BA59-FD5205AFA71E}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenTelemetry.Exporter.Geneva", "src\OpenTelemetry.Exporter.Geneva\OpenTelemetry.Exporter.Geneva.csproj", "{1105C814-31DA-4214-BEA8-6DB5FC12C808}"
EndProject
Expand Down

This file was deleted.

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

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
OpenTelemetry.Resources.ContainerResourceBuilderExtensions
static OpenTelemetry.Resources.ContainerResourceBuilderExtensions.AddContainerDetector(this OpenTelemetry.Resources.ResourceBuilder! builder) -> OpenTelemetry.Resources.ResourceBuilder!
10 changes: 10 additions & 0 deletions src/OpenTelemetry.Resources.Container/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

using System.Runtime.CompilerServices;

#if SIGNED
[assembly: InternalsVisibleTo("OpenTelemetry.Resources.Container.Tests, PublicKey=002400000480000094000000060200000024000052534131000400000100010051c1562a090fb0c9f391012a32198b5e5d9a60e9b80fa2d7b434c9e5ccb7259bd606e66f9660676afc6692b8cdc6793d190904551d2103b7b22fa636dcbb8208839785ba402ea08fc00c8f1500ccef28bbf599aa64ffb1e1d5dc1bf3420a3777badfe697856e9d52070a50c3ea5821c80bef17ca3acffa28f89dd413f096f898")]
#else
[assembly: InternalsVisibleTo("OpenTelemetry.Resources.Container.Tests")]
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,17 @@

* Update OpenTelemetry SDK version to `1.8.1`.
([#1668](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/1668))
* **Breaking Change**: Renamed package from `OpenTelemetry.ResourceDetectors.Container`
to `OpenTelemetry.Resources.Container`.
([#1849](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/1849))
* **Breaking Change**: `ContainerResourceDetector` type is now internal,
use `ResourceBuilder` extension method `AddContainerDetector`
to enable the detector.
([#1849](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/1849))
* **Breaking Change**: Renamed EventSource
from `OpenTelemetry-ResourceDetectors-Container`
to `OpenTelemetry-Resources-Container`.
([#1849](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/1849))

## 1.0.0-beta.7

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,14 @@
using System.Collections.Generic;
using System.IO;
using System.Text.RegularExpressions;
using OpenTelemetry.ResourceDetectors.Container.Utils;
using OpenTelemetry.Resources;
using OpenTelemetry.Resources.Container.Utils;

namespace OpenTelemetry.ResourceDetectors.Container;
namespace OpenTelemetry.Resources.Container;

/// <summary>
/// Resource detector for application running in Container environment.
/// </summary>
public class ContainerResourceDetector : IResourceDetector
internal sealed class ContainerDetector : IResourceDetector
{
private const string Filepath = "/proc/self/cgroup";
private const string FilepathV2 = "/proc/self/mountinfo";
Expand Down Expand Up @@ -170,7 +169,7 @@ private static string RemovePrefixAndSuffixIfNeeded(string input, int startIndex
}
catch (Exception ex)
{
ContainerExtensionsEventSource.Log.ExtractResourceAttributesException($"{nameof(ContainerResourceDetector)} : Failed to extract Container id from path", ex);
ContainerExtensionsEventSource.Log.ExtractResourceAttributesException($"{nameof(ContainerDetector)} : Failed to extract Container id from path", ex);
}

return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
using System.Diagnostics.Tracing;
using OpenTelemetry.Internal;

namespace OpenTelemetry.ResourceDetectors.Container;
namespace OpenTelemetry.Resources.Container;

[EventSource(Name = "OpenTelemetry-ResourceDetectors-Container")]
[EventSource(Name = "OpenTelemetry-Resources-Container")]
internal class ContainerExtensionsEventSource : EventSource
{
public static ContainerExtensionsEventSource Log = new();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

using OpenTelemetry.Internal;
using OpenTelemetry.Resources.Container;

namespace OpenTelemetry.Resources;

/// <summary>
/// Extension methods to simplify registering of Container resource detector.
/// </summary>
public static class ContainerResourceBuilderExtensions
{
/// <summary>
/// Enables Container resource detector.
/// </summary>
/// <param name="builder"><see cref="ResourceBuilder" /> being configured.</param>
/// <returns>The instance of <see cref="ResourceBuilder" /> being configured.</returns>
public static ResourceBuilder AddContainerDetector(this ResourceBuilder builder)
{
Guard.ThrowIfNull(builder);
return builder.AddDetector(new ContainerDetector());
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

namespace OpenTelemetry.ResourceDetectors.Container;
namespace OpenTelemetry.Resources.Container;

internal static class ContainerSemanticConventions
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<!-- OmniSharp/VS Code requires TargetFrameworks to be in descending order for IntelliSense and analysis. -->
<TargetFrameworks>$(NetMinimumSupportedVersion)</TargetFrameworks>
<Description>OpenTelemetry Extensions - Container Resource Detector from Container environment.</Description>
<MinVerTagPrefix>ResourceDetectors.Container-</MinVerTagPrefix>
<MinVerTagPrefix>Resources.Container-</MinVerTagPrefix>
</PropertyGroup>

<!--Do not run Package Baseline Validation as this package has never released a stable version.
Expand All @@ -18,5 +18,6 @@

<ItemGroup>
<Compile Include="$(RepoRoot)\src\Shared\ExceptionExtensions.cs" Link="Includes\ExceptionExtensions.cs" />
<Compile Include="$(RepoRoot)\src\Shared\Guard.cs" Link="Includes\Guard.cs" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# Container Resource Detectors

[![NuGet version badge](https://img.shields.io/nuget/v/OpenTelemetry.ResourceDetectors.Container)](https://www.nuget.org/packages/OpenTelemetry.ResourceDetectors.Container)
[![NuGet download count badge](https://img.shields.io/nuget/dt/OpenTelemetry.ResourceDetectors.Container)](https://www.nuget.org/packages/OpenTelemetry.ResourceDetectors.Container)
[![codecov.io](https://codecov.io/gh/open-telemetry/opentelemetry-dotnet-contrib/branch/main/graphs/badge.svg?flag=unittests-ResourceDetectors.Container)](https://app.codecov.io/gh/open-telemetry/opentelemetry-dotnet-contrib?flags[0]=unittests-ResourceDetectors.Container)
[![NuGet version badge](https://img.shields.io/nuget/v/OpenTelemetry.Resources.Container)](https://www.nuget.org/packages/OpenTelemetry.Resources.Container)
[![NuGet download count badge](https://img.shields.io/nuget/dt/OpenTelemetry.Resources.Container)](https://www.nuget.org/packages/OpenTelemetry.Resources.Container)
[![codecov.io](https://codecov.io/gh/open-telemetry/opentelemetry-dotnet-contrib/branch/main/graphs/badge.svg?flag=unittests-Resources.Container)](https://app.codecov.io/gh/open-telemetry/opentelemetry-dotnet-contrib?flags[0]=unittests-Resources.Container)

## Getting Started

You need to install the
`OpenTelemetry.ResourceDetectors.Container` package to be able to use the
`OpenTelemetry.Resources.Container` package to be able to use the
Container Resource Detectors.

```shell
dotnet add package OpenTelemetry.ResourceDetectors.Container --prerelease
dotnet add package OpenTelemetry.Resources.Container --prerelease
```

## Usage
Expand All @@ -21,19 +21,19 @@ the `TracerProvider` with the following example below.

```csharp
using OpenTelemetry;
using OpenTelemetry.ResourceDetectors.Container;
using OpenTelemetry.Resources.Container;

var tracerProvider = Sdk.CreateTracerProviderBuilder()
// other configurations
.ConfigureResource(resource => resource
.AddDetector(new ContainerResourceDetector()))
.AddContainerDetector())
.Build();
```

The resource detectors will record the following metadata based on where
your application is running:

- **ContainerResourceDetector**: container.id.
- **ContainerDetector**: container.id.

## References

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using System.Collections.Generic;
using System.Linq;

namespace OpenTelemetry.ResourceDetectors.Container.Utils;
namespace OpenTelemetry.Resources.Container.Utils;

internal class EncodingUtils
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@
<TrimmerRootAssembly Include="OpenTelemetry.Instrumentation.Runtime" />
<TrimmerRootAssembly Include="OpenTelemetry.Instrumentation.SqlClient" />
<TrimmerRootAssembly Include="OpenTelemetry.Instrumentation.StackExchangeRedis" />
<TrimmerRootAssembly Include="OpenTelemetry.ResourceDetectors.Container" />
<TrimmerRootAssembly Include="OpenTelemetry.Resources.AWS" />
<TrimmerRootAssembly Include="OpenTelemetry.Resources.Azure" />
<TrimmerRootAssembly Include="OpenTelemetry.Resources.Container" />
<TrimmerRootAssembly Include="OpenTelemetry.Resources.Host" />
<TrimmerRootAssembly Include="OpenTelemetry.Resources.Process" />
<TrimmerRootAssembly Include="OpenTelemetry.Resources.ProcessRuntime" />
Expand Down
Loading

0 comments on commit 4107ce2

Please sign in to comment.