honeycombio / libhoney-rb

Ruby library for sending data to Honeycomb
Apache License 2.0
11 stars 30 forks source link

`writekey` can be supplied via environment variable #14

Closed jazzdan closed 7 years ago

jazzdan commented 7 years ago

A common strategy for managing sensitive data such as API keys is to set them in the environment prior to starting a program that needs access to them. Then the program can read from the environment variable at runtime.

This commit enables a similar strategy to work with libhoney out of the box. If no writekey is supplied to Libhoney::Client it will check to see if the HONEYCOMB_WRITEKEY environment variable is set. If it is it will use that, otherwise it will use the empty string like it did before.

No worries if this is something that you'd envision being handled outside of the gem! It's just something I've seen handled inside in the gem in the past, and I found myself missing it when I reached for it.

jazzdan commented 7 years ago

@eanakashima Thanks for the feedback! Good point about the need to set the dataset name. I'll close this PR and open a new one that changes the README. :)