-
Notifications
You must be signed in to change notification settings - Fork 293
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
295 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
--- | ||
name: OpenTelemetry.ResourceDetectors.Process | ||
about: OpenTelemetry.ResourceDetectors.Process | ||
labels: comp:resourcedetectors.process | ||
--- | ||
|
||
# Issue with OpenTelemetry.ResourceDetectors.Process | ||
|
||
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
name: Pack OpenTelemetry.ResourceDetectors.Process | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
logLevel: | ||
description: 'Log level' | ||
required: true | ||
default: 'warning' | ||
push: | ||
tags: | ||
- 'ResourceDetectors.Process-*' # trigger when we create a tag with prefix "ResourceDetectors.Process-" | ||
|
||
jobs: | ||
call-build-test-pack: | ||
permissions: | ||
contents: write | ||
uses: ./.github/workflows/Component.Package.yml | ||
with: | ||
project-name: OpenTelemetry.ResourceDetectors.Process | ||
secrets: inherit |
32 changes: 32 additions & 0 deletions
32
build/Projects/OpenTelemetry.ResourceDetectors.Process.proj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<Project> | ||
|
||
<PropertyGroup> | ||
<RepoRoot>$([System.IO.Directory]::GetParent($(MSBuildThisFileDirectory)).Parent.Parent.FullName)</RepoRoot> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<SolutionProjects Include="$(RepoRoot)\src\OpenTelemetry.ResourceDetectors.Process\OpenTelemetry.ResourceDetectors.Process.csproj" /> | ||
<SolutionProjects Include="$(RepoRoot)\test\OpenTelemetry.ResourceDetectors.Process.Tests\OpenTelemetry.ResourceDetectors.Process.Tests.csproj" /> | ||
|
||
<PackProjects Include="$(RepoRoot)\src\OpenTelemetry.ResourceDetectors.Process\OpenTelemetry.ResourceDetectors.Process.csproj" /> | ||
|
||
<TestProjects Include="$(RepoRoot)\test\OpenTelemetry.ResourceDetectors.Process.Tests\OpenTelemetry.ResourceDetectors.Process.Tests.csproj" /> | ||
</ItemGroup> | ||
|
||
<Target Name="Build"> | ||
<MSBuild Projects="@(SolutionProjects)" Targets="Build" ContinueOnError="ErrorAndStop" /> | ||
</Target> | ||
|
||
<Target Name="Restore"> | ||
<MSBuild Projects="@(SolutionProjects)" Targets="Restore" ContinueOnError="ErrorAndStop" /> | ||
</Target> | ||
|
||
<Target Name="Pack"> | ||
<MSBuild Projects="@(PackProjects)" Targets="Pack" ContinueOnError="ErrorAndStop" /> | ||
</Target> | ||
|
||
<Target Name="VSTest"> | ||
<MSBuild Projects="@(TestProjects)" Targets="VSTest" ContinueOnError="ErrorAndStop" /> | ||
</Target> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
src/OpenTelemetry.ResourceDetectors.Process/.publicApi/net462/PublicAPI.Shipped.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
#nullable enable |
3 changes: 3 additions & 0 deletions
3
src/OpenTelemetry.ResourceDetectors.Process/.publicApi/net462/PublicAPI.Unshipped.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
OpenTelemetry.ResourceDetectors.Process.ProcessDetector | ||
OpenTelemetry.ResourceDetectors.Process.ProcessDetector.Detect() -> OpenTelemetry.Resources.Resource! | ||
OpenTelemetry.ResourceDetectors.Process.ProcessDetector.ProcessDetector() -> void |
1 change: 1 addition & 0 deletions
1
src/OpenTelemetry.ResourceDetectors.Process/.publicApi/net6.0/PublicAPI.Shipped.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
#nullable enable |
3 changes: 3 additions & 0 deletions
3
src/OpenTelemetry.ResourceDetectors.Process/.publicApi/net6.0/PublicAPI.Unshipped.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
OpenTelemetry.ResourceDetectors.Process.ProcessDetector | ||
OpenTelemetry.ResourceDetectors.Process.ProcessDetector.Detect() -> OpenTelemetry.Resources.Resource! | ||
OpenTelemetry.ResourceDetectors.Process.ProcessDetector.ProcessDetector() -> void |
10 changes: 10 additions & 0 deletions
10
src/OpenTelemetry.ResourceDetectors.Process/AssemblyInfo.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
using System.Runtime.CompilerServices; | ||
|
||
#if SIGNED | ||
[assembly: InternalsVisibleTo("OpenTelemetry.ResourceDetectors.Process.Tests, PublicKey=002400000480000094000000060200000024000052534131000400000100010051c1562a090fb0c9f391012a32198b5e5d9a60e9b80fa2d7b434c9e5ccb7259bd606e66f9660676afc6692b8cdc6793d190904551d2103b7b22fa636dcbb8208839785ba402ea08fc00c8f1500ccef28bbf599aa64ffb1e1d5dc1bf3420a3777badfe697856e9d52070a50c3ea5821c80bef17ca3acffa28f89dd413f096f898")] | ||
#else | ||
[assembly: InternalsVisibleTo("OpenTelemetry.ResourceDetectors.Process.Tests")] | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Changelog | ||
|
||
## Unreleased | ||
|
||
* Initial release of `OpenTelemetry.ResourceDetectors.Process` project | ||
[1506](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/1506) |
12 changes: 12 additions & 0 deletions
12
src/OpenTelemetry.ResourceDetectors.Process/OpenTelemetry.ResourceDetectors.Process.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<!-- OmniSharp/VS Code requires TargetFrameworks to be in descending order for IntelliSense and analysis. --> | ||
<TargetFrameworks>net6.0</TargetFrameworks> | ||
<TargetFrameworks Condition="$(OS) == 'Windows_NT'">$(TargetFrameworks);$(NetFrameworkMinimumSupportedVersion)</TargetFrameworks> | ||
<Description>OpenTelemetry Extensions - Process Resource Detector.</Description> | ||
<MinVerTagPrefix>ResourceDetectors.Process-</MinVerTagPrefix> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<PackageReference Include="OpenTelemetry" Version="1.6.0" /> | ||
</ItemGroup> | ||
</Project> |
32 changes: 32 additions & 0 deletions
32
src/OpenTelemetry.ResourceDetectors.Process/ProcessDetector.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
#if NET6_0_OR_GREATER | ||
using System; | ||
#endif | ||
using System.Collections.Generic; | ||
using OpenTelemetry.Resources; | ||
|
||
namespace OpenTelemetry.ResourceDetectors.Process; | ||
|
||
/// <summary> | ||
/// Process detector. | ||
/// </summary> | ||
public class ProcessDetector : IResourceDetector | ||
{ | ||
/// <summary> | ||
/// Detects the resource attributes for process. | ||
/// </summary> | ||
/// <returns>Resource with key-value pairs of resource attributes.</returns> | ||
public Resource Detect() | ||
{ | ||
return new Resource(new List<KeyValuePair<string, object>>(1) | ||
{ | ||
#if NET6_0_OR_GREATER | ||
new(ProcessSemanticConventions.AttributeProcessPid, Environment.ProcessId), | ||
#else | ||
new(ProcessSemanticConventions.AttributeProcessPid, System.Diagnostics.Process.GetCurrentProcess().Id), | ||
#endif | ||
}); | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
src/OpenTelemetry.ResourceDetectors.Process/ProcessSemanticConventions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
namespace OpenTelemetry.ResourceDetectors.Process; | ||
|
||
internal static class ProcessSemanticConventions | ||
{ | ||
public const string AttributeProcessPid = "process.pid"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Process Runtime Resource Detectors | ||
|
||
[![NuGet version badge](https://img.shields.io/nuget/v/OpenTelemetry.ResourceDetectors.Process)](https://www.nuget.org/packages/OpenTelemetry.ResourceDetectors.Process) | ||
[![NuGet download count badge](https://img.shields.io/nuget/dt/OpenTelemetry.ResourceDetectors.Process)](https://www.nuget.org/packages/OpenTelemetry.ResourceDetectors.Process) | ||
|
||
## Getting Started | ||
|
||
You need to install the | ||
`OpenTelemetry.ResourceDetectors.Process` package to be able to use the | ||
Process Runtime Resource Detectors. | ||
|
||
```shell | ||
dotnet add package OpenTelemetry.ResourceDetectors.Process --prerelease | ||
``` | ||
|
||
## Usage | ||
|
||
You can configure Process Runtime resource detector to | ||
the `TracerProvider` with the following example below. | ||
|
||
```csharp | ||
using OpenTelemetry; | ||
using OpenTelemetry.ResourceDetectors.Process; | ||
|
||
var tracerProvider = Sdk.CreateTracerProviderBuilder() | ||
// other configurations | ||
.ConfigureResource(resource => resource | ||
.AddDetector(new ProcessDetector())) | ||
.Build(); | ||
``` | ||
|
||
The resource detectors will record the following metadata based on where | ||
your application is running: | ||
|
||
- **ProcessDetector**: `process.pid`. | ||
|
||
## References | ||
|
||
- [OpenTelemetry Project](https://opentelemetry.io/) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
...etry.ResourceDetectors.Process.Tests/OpenTelemetry.ResourceDetectors.Process.Tests.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<Description>Unit test project for Process Detector for OpenTelemetry</Description> | ||
<!-- OmniSharp/VS Code requires TargetFrameworks to be in descending order for IntelliSense and analysis. --> | ||
<TargetFrameworks>$(SupportedNetTargets)</TargetFrameworks> | ||
<TargetFrameworks Condition="$(OS) == 'Windows_NT'">$(TargetFrameworks);$(NetFrameworkMinimumSupportedVersion)</TargetFrameworks> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="$(RepoRoot)\src\OpenTelemetry.ResourceDetectors.Process\OpenTelemetry.ResourceDetectors.Process.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
Oops, something went wrong.