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

[ci-visibility] Do not instrument tests if agentless is setup but no API key is provided #2072

Merged
merged 3 commits into from
May 31, 2022

Conversation

juan-fernandez
Copy link
Collaborator

@juan-fernandez juan-fernandez commented May 23, 2022

What does this PR do?

Do not call tracer.init if DD_CIVISIBILITY_AGENTLESS_ENABLED and no DATADOG_API_KEY is set, instead of falling back to the agent-based intake.

ℹ️ This is a breaking change but the feature is not GA yet, so no need for a major release.

Motivation

  • It aligns with the rest of the libraries.
  • The user has decided to explicitly opt in through DD_CIVISIBILITY_AGENTLESS_ENABLED but they have misconfigured the library, so it shouldn't fallback to the agent-based intake.

Plugin Checklist

Additional Notes

@codecov
Copy link

codecov bot commented May 23, 2022

Codecov Report

Merging #2072 (ad1b2bc) into master (edc3406) will decrease coverage by 0.08%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##           master    #2072      +/-   ##
==========================================
- Coverage   92.89%   92.81%   -0.09%     
==========================================
  Files         207      207              
  Lines        8264     8291      +27     
==========================================
+ Hits         7677     7695      +18     
- Misses        587      596       +9     
Impacted Files Coverage Δ
packages/datadog-plugin-amqplib/src/index.js
packages/datadog-instrumentations/src/amqplib.js
packages/datadog-plugin-kafkajs/src/index.js 97.14% <0.00%> (ø)
packages/datadog-instrumentations/src/kafkajs.js 87.09% <0.00%> (ø)

📣 Codecov can now indicate which changes are the most critical in Pull Requests. Learn more

@juan-fernandez juan-fernandez marked this pull request as ready for review May 24, 2022 09:01
@juan-fernandez juan-fernandez requested a review from a team as a code owner May 24, 2022 09:01
ci/init.js Outdated
exporter: 'datadog'
}
} else {
console.error(`
Copy link
Collaborator

Choose a reason for hiding this comment

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

Since the tracer is loaded, but not initialized, is the logger available at this point? If so, it should be used here. If not, then nevermind.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

that's a good question. I'll try

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

indeed, log.error won't work because it's not enabled (https://github.com/DataDog/dd-trace-js/blob/master/packages/dd-trace/src/log.js#L115). Using console.error is a bit aggressive but the way to get it is not straightforward. You have to use ci visibility's entrypoint and opt in to agentless via the flag. At that point I think it's fine to warn users that they've messed up their setup (by missing their API key)

@juan-fernandez juan-fernandez requested a review from bengl May 26, 2022 09:47
@juan-fernandez
Copy link
Collaborator Author

@bengl did you have time to have a look at this again?

@juan-fernandez juan-fernandez merged commit ca465ed into master May 31, 2022
@juan-fernandez juan-fernandez deleted the juan-fernandez/fail-dd-api-key-missing branch May 31, 2022 15:12
simon-id pushed a commit that referenced this pull request Jun 8, 2022
rochdev pushed a commit that referenced this pull request Jun 8, 2022
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.

None yet

2 participants