-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
[exporter/datadog] Add api.fail_on_invalid_key
to fail fast if API Key is invalid
#9426
[exporter/datadog] Add api.fail_on_invalid_key
to fail fast if API Key is invalid
#9426
Conversation
f95233b
to
4e2d4cc
Compare
api.fail_on_invalid_key
to fail fast if API Key is invalid.
api.fail_on_invalid_key
to fail fast if API Key is invalid.api.fail_on_invalid_key
to fail fast if API Key is invalid
4e2d4cc
to
14f929f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know if a config option is appropriate here. If configuration is invalid, the component should always fail IMO. If an exporter cannot be started as configured, it should return the error in its newMetricsExporter
function, for example.
I agree in principle, but there is some internal hesitancy to failing to start by default because of a feature that may be added to Datadog in the future related to API keys, so I think we want it behind a flag, even if I agree this looks odd from the outside |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for doing this! My main comment is that instead of panicking with logger.Fatal
, we should return an error. I left some other comments inline
3f1f106
to
e3c8cf2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, thanks for addressing the comments! 🙇 Just two tiny nits, after those are addressed I will wait for David to ACK my comment and then mark as ready to merge
It looks like you also need to address some lint errors: https://github.com/open-telemetry/opentelemetry-collector-contrib/runs/6209762394?check_suite_focus=true |
Closing and re-opening PR to trigger the |
Looks like it passed now |
@@ -198,6 +198,7 @@ func (f *factory) createTracesExporter( | |||
} | |||
|
|||
ctx, cancel := context.WithCancel(ctx) | |||
defer cancel() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually this cancels the exporter prematurely after the function exits. The cancel is only meant to be called on shutdown (it is part of shutdown, so technically it does get called on all paths).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(it is part of shutdown, so technically it does get called on all paths).
the lint was failing because it was not called when the traces exporter fails to get created. I opened #9797 to fix this, thanks for spotting that!
…Key is invalid (open-telemetry#9426) * add new `fail_on_invalid_key` option * improve the description of fail_on_invalid_key * avoid failing when a transient network error * remove unnecessary comment * utils.ValidateAPI() returns error * add tests * not returning error when api failure * fix test names * fix lint * fix go vet: prevent possible context leak Co-authored-by: Alex Boten <[email protected]>
Description:
Add
api.fail_on_invalid_key
to fail fast if API Key is invalid.Link to tracking Issue:
#7402
Testing:
fail_on_invalid_key: false
1 ) Set the invalid API key and
fail_on_invalid_key: false
.2 )
make run
3 ) Confirming error message
This behavior is same as before.
fail_on_invalid_key: true
1 ) Set the invalid API key and
fail_on_invalid_key: true
.2 )
make run
3 ) Confirming error message
Documentation: