Skip to content

Commit

Permalink
Merge branch 'main' into issue/AWS-Lambda-SQS-SNS-support
Browse files Browse the repository at this point in the history
  • Loading branch information
utpilla authored May 15, 2023
2 parents 8e1c8df + d3f70ef commit 8c8b9a0
Show file tree
Hide file tree
Showing 81 changed files with 957 additions and 433 deletions.
41 changes: 41 additions & 0 deletions .github/ISSUE_TEMPLATE/comp_resourcedetectors_aws.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
---
name: OpenTelemetry.ResourceDetectors.AWS
about: Issue with OpenTelemetry.ResourceDetectors.AWS
labels: comp:resourcedetectors.aws
---

# Issue with OpenTelemetry.ResourceDetectors.AWS

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.
6 changes: 6 additions & 0 deletions .github/component_owners.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ components:
- xiang17
src/OpenTelemetry.Instrumentation.Wcf/:
- codeblanch
src/OpenTelemetry.ResourceDetectors.AWS/:
- srprash
- atshaw43
src/OpenTelemetry.ResourceDetectors.Azure/:
- rajkumar-rangaraj
- vishweshbankwar
Expand Down Expand Up @@ -136,6 +139,9 @@ components:
- xiang17
test/OpenTelemetry.Instrumentation.Wcf.Tests/:
- codeblanch
test/OpenTelemetry.ResourceDetectors.AWS.Tests/:
- srprash
- atshaw43
test/OpenTelemetry.ResourceDetectors.Azure.Tests/:
- rajkumar-rangaraj
- vishweshbankwar
Expand Down
67 changes: 67 additions & 0 deletions .github/workflows/package-ResourceDetectors.AWS.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: Pack OpenTelemetry.ResourceDetectors.AWS

on:
workflow_dispatch:
inputs:
logLevel:
description: 'Log level'
required: true
default: 'warning'
push:
tags:
- 'ResourceDetectors.AWS-*' # trigger when we create a tag with prefix "ResourceDetectors.AWS-"

jobs:
build-test-pack:
runs-on: ${{ matrix.os }}
permissions:
contents: write
env:
PROJECT: OpenTelemetry.ResourceDetectors.AWS

strategy:
matrix:
os: [windows-latest]

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # fetching all

- uses: actions/setup-dotnet@v3.0.3
with:
dotnet-version: '7.0.x'

- name: Install dependencies
run: dotnet restore src/${{env.PROJECT}}

- name: dotnet build ${{env.PROJECT}}
run: dotnet build src/${{env.PROJECT}} --configuration Release --no-restore -p:Deterministic=true

- name: dotnet test ${{env.PROJECT}}
run: dotnet test test/${{env.PROJECT}}.Tests

- name: dotnet pack ${{env.PROJECT}}
run: dotnet pack src/${{env.PROJECT}} --configuration Release --no-build

- name: Publish Artifacts
uses: actions/upload-artifact@v3
with:
name: ${{env.PROJECT}}-packages
path: '**/${{env.PROJECT}}/bin/**/*.*nupkg'

- name: Publish Nuget
run: |
nuget push **/${{env.PROJECT}}/bin/**/*.nupkg -Source https://api.nuget.org/v3/index.json -ApiKey ${{ secrets.NUGET_TOKEN }} -SymbolApiKey ${{ secrets.NUGET_TOKEN }}
- name: Create GitHub Prerelease
if: ${{ (contains(github.ref_name, '-alpha.') || contains(github.ref_name, '-beta.') || contains(github.ref_name, '-rc.')) }}
run: gh release create ${{ github.ref_name }} --title ${{ github.ref_name }} --verify-tag --notes "See [CHANGELOG](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/blob/${{ github.ref_name }}/src/${{env.PROJECT}}/CHANGELOG.md) for details." --prerelease
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Create GitHub Release
if: ${{ !(contains(github.ref_name, '-alpha.') || contains(github.ref_name, '-beta.') || contains(github.ref_name, '-rc.')) }}
run: gh release create ${{ github.ref_name }} --title ${{ github.ref_name }} --verify-tag --notes "See [CHANGELOG](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/blob/${{ github.ref_name }}/src/${{env.PROJECT}}/CHANGELOG.md) for details." --latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
14 changes: 14 additions & 0 deletions opentelemetry-dotnet-contrib.sln
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Shared", "Shared", "{1FCC8E
src\Shared\SpanHelper.cs = src\Shared\SpanHelper.cs
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenTelemetry.ResourceDetectors.AWS", "src\OpenTelemetry.ResourceDetectors.AWS\OpenTelemetry.ResourceDetectors.AWS.csproj", "{71BABAC0-E299-48BF-93E2-C11C3840B037}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenTelemetry.ResourceDetectors.AWS.Tests", "test\OpenTelemetry.ResourceDetectors.AWS.Tests\OpenTelemetry.ResourceDetectors.AWS.Tests.csproj", "{DE898A1E-920E-476F-B0DB-A98AFD6E3BF4}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -590,6 +594,14 @@ Global
{9B7F7605-ADFF-4A47-9B64-FFF3E2EC9DEA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9B7F7605-ADFF-4A47-9B64-FFF3E2EC9DEA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9B7F7605-ADFF-4A47-9B64-FFF3E2EC9DEA}.Release|Any CPU.Build.0 = Release|Any CPU
{71BABAC0-E299-48BF-93E2-C11C3840B037}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{71BABAC0-E299-48BF-93E2-C11C3840B037}.Debug|Any CPU.Build.0 = Debug|Any CPU
{71BABAC0-E299-48BF-93E2-C11C3840B037}.Release|Any CPU.ActiveCfg = Release|Any CPU
{71BABAC0-E299-48BF-93E2-C11C3840B037}.Release|Any CPU.Build.0 = Release|Any CPU
{DE898A1E-920E-476F-B0DB-A98AFD6E3BF4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DE898A1E-920E-476F-B0DB-A98AFD6E3BF4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DE898A1E-920E-476F-B0DB-A98AFD6E3BF4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DE898A1E-920E-476F-B0DB-A98AFD6E3BF4}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -680,6 +692,8 @@ Global
{9B7F7605-ADFF-4A47-9B64-FFF3E2EC9DEA} = {93503FAF-D43D-48C0-818C-92EB90F7606B}
{93503FAF-D43D-48C0-818C-92EB90F7606B} = {B75EE478-97F7-4E9F-9A5A-DB3D0988EDEA}
{1FCC8EEC-9E75-4FEA-AFCF-363DD33FF0B9} = {22DF5DC0-1290-4E83-A9D8-6BB7DE3B3E63}
{71BABAC0-E299-48BF-93E2-C11C3840B037} = {22DF5DC0-1290-4E83-A9D8-6BB7DE3B3E63}
{DE898A1E-920E-476F-B0DB-A98AFD6E3BF4} = {2097345F-4DD3-477D-BC54-A922F9B2B402}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {B0816796-CDB3-47D7-8C3C-946434DE3B66}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,9 @@
OpenTelemetry.Contrib.Extensions.AWSXRay.AWSXRayIdGenerator
OpenTelemetry.Contrib.Extensions.AWSXRay.Resources.AWSEBSResourceDetector
OpenTelemetry.Contrib.Extensions.AWSXRay.Resources.AWSEBSResourceDetector.AWSEBSResourceDetector() -> void
OpenTelemetry.Contrib.Extensions.AWSXRay.Resources.AWSEBSResourceDetector.Detect() -> OpenTelemetry.Resources.Resource!
OpenTelemetry.Contrib.Extensions.AWSXRay.Resources.AWSEC2ResourceDetector
OpenTelemetry.Contrib.Extensions.AWSXRay.Resources.AWSEC2ResourceDetector.AWSEC2ResourceDetector() -> void
OpenTelemetry.Contrib.Extensions.AWSXRay.Resources.AWSEC2ResourceDetector.Detect() -> OpenTelemetry.Resources.Resource!
OpenTelemetry.Contrib.Extensions.AWSXRay.Resources.ResourceDetectorUtils
OpenTelemetry.Contrib.Extensions.AWSXRay.Resources.ResourceDetectorUtils.ResourceDetectorUtils() -> void
OpenTelemetry.Contrib.Extensions.AWSXRay.Trace.AWSXRayPropagator
OpenTelemetry.Contrib.Extensions.AWSXRay.Trace.AWSXRayPropagator.AWSXRayPropagator() -> void
OpenTelemetry.Trace.TracerProviderBuilderExtensions
override OpenTelemetry.Contrib.Extensions.AWSXRay.Trace.AWSXRayPropagator.Extract<T>(OpenTelemetry.Context.Propagation.PropagationContext context, T carrier, System.Func<T, string!, System.Collections.Generic.IEnumerable<string!>!>! getter) -> OpenTelemetry.Context.Propagation.PropagationContext
override OpenTelemetry.Contrib.Extensions.AWSXRay.Trace.AWSXRayPropagator.Fields.get -> System.Collections.Generic.ISet<string!>!
override OpenTelemetry.Contrib.Extensions.AWSXRay.Trace.AWSXRayPropagator.Inject<T>(OpenTelemetry.Context.Propagation.PropagationContext context, T carrier, System.Action<T, string!, string!>! setter) -> void
static OpenTelemetry.Trace.TracerProviderBuilderExtensions.AddXRayTraceId(this OpenTelemetry.Trace.TracerProviderBuilder! builder) -> OpenTelemetry.Trace.TracerProviderBuilder!
static OpenTelemetry.Trace.TracerProviderBuilderExtensions.AddXRayTraceIdWithSampler(this OpenTelemetry.Trace.TracerProviderBuilder! builder, OpenTelemetry.Trace.Sampler! sampler) -> OpenTelemetry.Trace.TracerProviderBuilder!
static OpenTelemetry.Trace.TracerProviderBuilderExtensions.AddXRayTraceIdWithSampler(this OpenTelemetry.Trace.TracerProviderBuilder! builder, OpenTelemetry.Trace.Sampler! sampler) -> OpenTelemetry.Trace.TracerProviderBuilder!
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
#nullable enable
*REMOVED*OpenTelemetry.Contrib.Extensions.AWSXRay.Resources.AWSEBSResourceDetector.Detect() -> System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<string, object>>
OpenTelemetry.Contrib.Extensions.AWSXRay.Resources.AWSEBSResourceDetector.Detect() -> OpenTelemetry.Resources.Resource!
*REMOVED*OpenTelemetry.Contrib.Extensions.AWSXRay.Resources.AWSEC2ResourceDetector.Detect() -> System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<string, object>>
OpenTelemetry.Contrib.Extensions.AWSXRay.Resources.AWSEC2ResourceDetector.Detect() -> OpenTelemetry.Resources.Resource!
*REMOVED*OpenTelemetry.Contrib.Extensions.AWSXRay.Resources.AWSECSResourceDetector.Detect() -> System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<string, object>>
OpenTelemetry.Contrib.Extensions.AWSXRay.Resources.AWSECSResourceDetector.Detect() -> OpenTelemetry.Resources.Resource!
*REMOVED*OpenTelemetry.Contrib.Extensions.AWSXRay.Resources.AWSEKSResourceDetector.Detect() -> System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<string, object>>
OpenTelemetry.Contrib.Extensions.AWSXRay.Resources.AWSEKSResourceDetector.Detect() -> OpenTelemetry.Resources.Resource!
*REMOVED*OpenTelemetry.Contrib.Extensions.AWSXRay.Resources.AWSLambdaResourceDetector.Detect() -> System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<string, object>>
OpenTelemetry.Contrib.Extensions.AWSXRay.Resources.AWSLambdaResourceDetector.Detect() -> OpenTelemetry.Resources.Resource!
*REMOVED*OpenTelemetry.Contrib.Extensions.AWSXRay.Resources.AWSLambdaResourceDetector.Detect() -> System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<string!, object?>>?'
*REMOVED*OpenTelemetry.Contrib.Extensions.AWSXRay.Resources.AWSLambdaResourceDetector.Detect() -> System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<string!, object?>>?
*REMOVED*OpenTelemetry.Contrib.Extensions.AWSXRay.Resources.AWSEBSResourceDetector
*REMOVED*OpenTelemetry.Contrib.Extensions.AWSXRay.Resources.AWSEBSResourceDetector.AWSEBSResourceDetector() -> void
*REMOVED*OpenTelemetry.Contrib.Extensions.AWSXRay.Resources.AWSEBSResourceDetector.Detect() -> System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<string!, object?>>?
*REMOVED*OpenTelemetry.Contrib.Extensions.AWSXRay.Resources.AWSEC2ResourceDetector
*REMOVED*OpenTelemetry.Contrib.Extensions.AWSXRay.Resources.AWSEC2ResourceDetector.AWSEC2ResourceDetector() -> void
*REMOVED*OpenTelemetry.Contrib.Extensions.AWSXRay.Resources.AWSEC2ResourceDetector.Detect() -> System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<string!, object?>>?
*REMOVED*OpenTelemetry.Contrib.Extensions.AWSXRay.Resources.AWSECSResourceDetector
*REMOVED*OpenTelemetry.Contrib.Extensions.AWSXRay.Resources.AWSECSResourceDetector.AWSECSResourceDetector() -> void
*REMOVED*OpenTelemetry.Contrib.Extensions.AWSXRay.Resources.AWSECSResourceDetector.Detect() -> System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<string!, object?>>?
*REMOVED*OpenTelemetry.Contrib.Extensions.AWSXRay.Resources.AWSEKSResourceDetector
*REMOVED*OpenTelemetry.Contrib.Extensions.AWSXRay.Resources.AWSEKSResourceDetector.AWSEKSResourceDetector() -> void
*REMOVED*OpenTelemetry.Contrib.Extensions.AWSXRay.Resources.AWSEKSResourceDetector.Detect() -> System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<string!, object?>>?
*REMOVED*OpenTelemetry.Contrib.Extensions.AWSXRay.Resources.AWSLambdaResourceDetector
*REMOVED*OpenTelemetry.Contrib.Extensions.AWSXRay.Resources.AWSLambdaResourceDetector.AWSLambdaResourceDetector() -> void
*REMOVED*OpenTelemetry.Contrib.Extensions.AWSXRay.Resources.AWSLambdaResourceDetector.Detect() -> System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<string!, object?>>?
*REMOVED*OpenTelemetry.Contrib.Extensions.AWSXRay.Resources.IResourceDetector
*REMOVED*OpenTelemetry.Contrib.Extensions.AWSXRay.Resources.IResourceDetector.Detect() -> System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<string!, object?>>?
*REMOVED*OpenTelemetry.Resources.ResourceBuilderExtensions
*REMOVED*static OpenTelemetry.Resources.ResourceBuilderExtensions.AddDetector(this OpenTelemetry.Resources.ResourceBuilder resourceBuilder, OpenTelemetry.Contrib.Extensions.AWSXRay.Resources.IResourceDetector resourceDetector) -> OpenTelemetry.Resources.ResourceBuilder
*REMOVED*OpenTelemetry.Contrib.Extensions.AWSXRay.Resources.ResourceDetectorUtils
*REMOVED*OpenTelemetry.Contrib.Extensions.AWSXRay.Resources.ResourceDetectorUtils.ResourceDetectorUtils() -> void
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ namespace OpenTelemetry.Contrib.Extensions.AWSXRay;
[EventSource(Name = "OpenTelemetry-AWS-XRay")]
internal class AWSXRayEventSource : EventSource
{
public static AWSXRayEventSource Log = new AWSXRayEventSource();
public static AWSXRayEventSource Log = new();

[NonEvent]
public void ActivityContextExtractException(string format, Exception ex)
Expand All @@ -34,15 +34,6 @@ public void ActivityContextExtractException(string format, Exception ex)
}
}

[NonEvent]
public void ResourceAttributesExtractException(string format, Exception ex)
{
if (this.IsEnabled(EventLevel.Warning, (EventKeywords)(-1)))
{
this.FailedToExtractResourceAttributes(format, ex.ToInvariantString());
}
}

[Event(1, Message = "Failed to extract activity context in format: '{0}', context: '{1}'.", Level = EventLevel.Warning)]
public void FailedToExtractActivityContext(string format, string exception)
{
Expand All @@ -54,16 +45,4 @@ public void FailedToInjectActivityContext(string format, string error)
{
this.WriteEvent(2, format, error);
}

[Event(3, Message = "Failed to extract resource attributes in '{0}'.", Level = EventLevel.Warning)]
public void FailedToExtractResourceAttributes(string format, string exception)
{
this.WriteEvent(3, format, exception);
}

[Event(4, Message = "Failed to validate certificate in format: '{0}', error: '{1}'.", Level = EventLevel.Warning)]
public void FailedToValidateCertificate(string format, string error)
{
this.WriteEvent(4, format, error);
}
}
6 changes: 6 additions & 0 deletions src/OpenTelemetry.Contrib.Extensions.AWSXRay/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@
supporting ResourceBuilderExtensions extension, and migrate all detectors to
implement OpenTelemetry.Resources.IResourceDetector
([#875](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/875))
* Drop support for `AWSLambdaResourceDetector`.
AWS Lambda Resources are detected by `OpenTelemetry.Instrumentation.AWSLambda`
package
([#1140](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/1140))
* Extract AWS Resource Detectors to dedicated package `OpenTelemetry.ResourceDetectors.AWS`
([#1140](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/1140))

## 1.2.0

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,6 @@
<PackageReference Include="System.Net.Http" Version="4.3.4" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == '$(NetFrameworkMinimumSupportedVersion)'">
<Compile Remove="Resources\AWSECSResourceDetector.cs" />
<Compile Remove="Resources\AWSEKSResourceDetector.cs" />
<Compile Remove="Resources\AWSLambdaResourceDetector.cs" />
<Compile Remove="Resources\Http\Handler.cs" />
<Compile Remove="Resources\Http\ServerCertificateValidationProvider.cs" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0' Or '$(TargetFramework)' == '$(NetFrameworkMinimumSupportedVersion)'">
<PackageReference Include="System.Text.Json" Version="6.0.0" />
</ItemGroup>
Expand Down
33 changes: 0 additions & 33 deletions src/OpenTelemetry.Contrib.Extensions.AWSXRay/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,39 +38,6 @@ var tracerProvider = Sdk.CreateTracerProviderBuilder()
Sdk.SetDefaultTextMapPropagator(new AWSXRayPropagator());
```

### AWS Resource Detectors

The ADOT .NET SDK supports automatically recording metadata in
EC2, Elastic Beanstalk, ECS, and EKS environments. You can configure
the corresponding resource detector to the `TracerProvider` following
the EC2 example below.

```csharp
using OpenTelemetry;
using OpenTelemetry.Contrib.Extensions.AWSXRay.Resources;
using OpenTelemetry.Resources;

var tracerProvider = Sdk.CreateTracerProviderBuilder()
// other configurations
.SetResourceBuilder(ResourceBuilder
.CreateDefault()
.AddDetector(new AWSEC2ResourceDetector()))
.Build();
```

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

- **AWSEC2ResourceDetector**: cloud provider, cloud platform, account id,
cloud available zone, host id, host type, aws region, host name.
- **AWSEBSResourceDetector**: cloud provider, cloud platform, service name,
service namespace, instance id, service version.
- **AWSECSResourceDetector**: cloud provider, cloud platform, container id.
- **AWSEKSResourceDetector**: cloud provider, cloud platform, cluster name,
container id.
- **AWSLambdaResourceDetector**: cloud provider, cloud platform, aws region,
function name, function version.

## References

- [OpenTelemetry Project](https://opentelemetry.io/)
Expand Down
Loading

0 comments on commit 8c8b9a0

Please sign in to comment.