Skip to content

Added resource detectors for AWS services#149

Merged
srprash merged 16 commits into
open-telemetry:mainfrom
lupengamzn:main
Sep 17, 2021
Merged

Added resource detectors for AWS services#149
srprash merged 16 commits into
open-telemetry:mainfrom
lupengamzn:main

Conversation

@lupengamzn

@lupengamzn lupengamzn commented Aug 16, 2021

Copy link
Copy Markdown
Contributor

PR for adding resource detectors for AWS services.

Currently the OpenTelemetry .NET SDK hasn't expose the AddDetector API and Resource class. This is a workaround to provide customers the APIs to opt-in resource detectors with the same user experience. Once the upstream provides the resource detector APIs, will switch to that in future.

@codecov

codecov Bot commented Aug 16, 2021

Copy link
Copy Markdown

Codecov Report

Merging #149 (32c2b4b) into main (844a3cf) will decrease coverage by 0.54%.
The diff coverage is 72.87%.

❗ Current head 32c2b4b differs from pull request most recent head 9fb6bb3. Consider uploading reports for the commit 9fb6bb3 to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##             main     #149      +/-   ##
==========================================
- Coverage   79.17%   78.62%   -0.55%     
==========================================
  Files          68       79      +11     
  Lines        1796     1984     +188     
==========================================
+ Hits         1422     1560     +138     
- Misses        374      424      +50     
Impacted Files Coverage Δ
...y.Contrib.Extensions.AWSXRay/AWSXRayEventSource.cs 15.78% <40.00%> (+15.78%) ⬆️
...nsions.AWSXRay/Resources/AWSEKSResourceDetector.cs 58.82% <58.82%> (ø)
...nsions.AWSXRay/Resources/AWSECSResourceDetector.cs 67.85% <67.85%> (ø)
...nsions.AWSXRay/Resources/AWSEC2ResourceDetector.cs 68.96% <68.96%> (ø)
...ons.AWSXRay/Resources/ResourceBuilderExtensions.cs 83.33% <83.33%> (ø)
...ons.AWSXRay/Resources/AWSLambdaResourceDetector.cs 84.21% <84.21%> (ø)
...nsions.AWSXRay/Resources/AWSEBSResourceDetector.cs 86.95% <86.95%> (ø)
...ensions.AWSXRay/Resources/ResourceDetectorUtils.cs 88.23% <88.23%> (ø)
...ns.AWSXRay/Resources/Models/AWSEBSMetadataModel.cs 100.00% <100.00%> (ø)
...ay/Resources/Models/AWSEC2IdentityDocumentModel.cs 100.00% <100.00%> (ø)
... and 14 more

@lupengamzn lupengamzn marked this pull request as ready for review September 7, 2021 18:03
@lupengamzn lupengamzn requested a review from srprash as a code owner September 7, 2021 18:03
@lupengamzn lupengamzn requested a review from a team September 7, 2021 18:03

@srprash srprash left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding these resource detectors!
We would also need a README for users with instructions and example on using them.

Comment thread src/OpenTelemetry.Contrib.Extensions.AWSXRay/Resources/AWSEBSResourceDetector.cs Outdated
Comment thread src/OpenTelemetry.Contrib.Extensions.AWSXRay/Resources/AWSECSResourceDetector.cs Outdated
Comment thread src/OpenTelemetry.Contrib.Extensions.AWSXRay/Resources/AWSEKSResourceDetector.cs Outdated
Comment thread src/OpenTelemetry.Contrib.Extensions.AWSXRay/Resources/AWSEKSResourceDetector.cs Outdated
@srprash

srprash commented Sep 13, 2021

Copy link
Copy Markdown
Contributor

Also, the unit test coverage seems to be very low. Can you add more tests to cover the resource detectors?

filePath = AWSEBSMetadataWindowsFilePath;
#endif

var metadata = this.GetEBSMetadata(filePath);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can unit test this by using a mock file system. For instance, if we use the interfaces defined in https://www.nuget.org/packages/System.IO.Abstractions/13.2.47 to interact with the file system, maybe we can add a new utility method where the file system is configurable, and we can pass in a fake file system to mock the responses it gives?

We can also extract all of this logic into a helper method if we need to pass in a new file system for testing, since I know we can't touch the Detect() API.

@willarmiros willarmiros left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added suggestions for unit test coverage

/// </summary>
public class ResourceDetectorUtils
{
internal static async Task<string> SendOutRequest(string url, string method, KeyValuePair<string, string> header, HttpClientHandler handler = null)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method could also be tested using WireMock or something similar to mock a server, but I think that's probably lower priority given it's just testing the HTTP client.

Comment thread src/OpenTelemetry.Contrib.Extensions.AWSXRay/Resources/AWSEKSResourceDetector.cs Outdated
Comment thread src/OpenTelemetry.Contrib.Extensions.AWSXRay/Resources/AWSEKSResourceDetector.cs Outdated

@willarmiros willarmiros left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's sync offline on codecov, otherwise looking good!

Comment thread src/OpenTelemetry.Contrib.Extensions.AWSXRay/README.md Outdated

@willarmiros willarmiros left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Will wait for @srprash approval

@srprash srprash left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A minor call out.
Everything else looks good. Thanks for adding in all those tests. :)

@srprash srprash merged commit 5071048 into open-telemetry:main Sep 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants