Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(detector-aws): add DetectorSync implementation for EC2 detector #2332

Closed

Conversation

david-luna
Copy link
Contributor

@david-luna david-luna commented Jul 12, 2024

Context

Another PR moving away from the deprecated Detector interface in favour to the DetectorSync interface. This time is for AWS EC2 detector and it might help a bit in open-telemetry/opentelemetry-js#3582

Not doing all detectors at once:

  • detectors are independent from each other
  • smaller PRs for faster reviews

Short description of the changes

  • add AwsEc2DetectorSync class and instance
  • make AwsEc2Detector reuse the new sync instance
  • update tests

Note: since this package is marked as stable (major version is 1) we are doing a non breaking change by adding the new class and mark the current as deprecated. The async detector changes behavior, it does not throw anymore, and it was discussed in last SIG meeting (2024-07-31). The outcome was we're okay with that.

A couple of PRs will follow:

  • one to suppress internal tracing.
  • one to add the sync detector to auto-instrumentations package.

@david-luna david-luna requested a review from a team July 12, 2024 11:28
@@ -235,7 +235,11 @@ function getDisabledInstrumentationsFromEnv() {
export function getResourceDetectorsFromEnv(): Array<Detector | DetectorSync> {
const resourceDetectors = new Map<
string,
Detector | DetectorSync | Detector[] | DetectorSync[]
| Detector
Copy link
Contributor Author

Choose a reason for hiding this comment

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

note for reviewer: this is necessary to allow this single refactor instead of doing all AWS detector at once.

Copy link

codecov bot commented Jul 12, 2024

Codecov Report

Attention: Patch coverage is 98.24561% with 1 line in your changes missing coverage. Please review.

Project coverage is 90.41%. Comparing base (dfb2dff) to head (eac609b).
Report is 199 commits behind head on main.

Files Patch % Lines
...e-detector-aws/src/detectors/AwsEc2DetectorSync.ts 98.07% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2332      +/-   ##
==========================================
- Coverage   90.97%   90.41%   -0.56%     
==========================================
  Files         146      150       +4     
  Lines        7492     7368     -124     
  Branches     1502     1527      +25     
==========================================
- Hits         6816     6662     -154     
- Misses        676      706      +30     
Files Coverage Δ
...ource-detector-aws/src/detectors/AwsEc2Detector.ts 100.00% <100.00%> (+2.08%) ⬆️
...metry-resource-detector-aws/src/detectors/index.ts 100.00% <100.00%> (ø)
...tapackages/auto-instrumentations-node/src/utils.ts 98.19% <ø> (-0.59%) ⬇️
...e-detector-aws/src/detectors/AwsEc2DetectorSync.ts 98.07% <98.07%> (ø)

... and 67 files with indirect coverage changes

@david-luna david-luna changed the title refactor(detector-aws): change implementation to DetectorSync interface for EC2 detector feat(detector-aws): add DetectorSync implementation for EC2 detector Aug 1, 2024
@@ -14,7 +14,8 @@
* limitations under the License.
*/

export * from './AwsEc2Detector';
export { awsEc2Detector } from './AwsEc2Detector';
Copy link
Contributor Author

Choose a reason for hiding this comment

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

note for reviewer: small step forward for open-telemetry/opentelemetry-js#4186

const AWS_HOST_PATH = awsEc2Detector.AWS_INSTANCE_HOST_DOCUMENT_PATH;
const AWS_METADATA_TTL_HEADER = awsEc2Detector.AWS_METADATA_TTL_HEADER;
const AWS_METADATA_TOKEN_HEADER = awsEc2Detector.AWS_METADATA_TOKEN_HEADER;
const AWS_HOST = 'http://' + awsEc2DetectorSync.AWS_IDMS_ENDPOINT;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

note for reviewer: the awsEc2Detector becomes a mere wrapper of awsEc2DetectorSync, we need to import the later to set these values.

@david-luna
Copy link
Contributor Author

closed in favour of #2376 following this suggestion

@david-luna david-luna closed this Aug 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants