From 8beb7b7fa79f4e6a31acfa7e8b11cd3910bef5fb Mon Sep 17 00:00:00 2001 From: eheinlein Date: Thu, 16 Jan 2020 14:37:27 -0800 Subject: [PATCH] Improve docs around API key meaning --- README.md | 7 ++++--- cumulative/cumulative_test.go | 2 +- examples/server/main.go | 2 +- telemetry/README.md | 2 +- telemetry/aggregated_metrics_test.go | 6 +++--- telemetry/config.go | 5 +++-- telemetry/example_test.go | 8 ++++---- 7 files changed, 17 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index e1943ca..d47f65a 100644 --- a/README.md +++ b/README.md @@ -32,8 +32,9 @@ automatic harvesting on a given schedule, and handling of errors from the API response. It also provides the ability to aggregate individual data points into metrics. -This example code assumes you've set the the `NEW_RELIC_API_KEY` environment -variable to your Insights Insert API Key. A larger example is provided in +This example code assumes you've set the the `NEW_RELIC_INSIGHTS_INSERT_API_KEY` +environment variable to your Insights Insert API Key. A larger example is +provided in [examples/server/main.go](./examples/server/main.go). ```go @@ -50,7 +51,7 @@ import ( func main() { // First create a Harvester. APIKey is the only required field. - h, err := telemetry.NewHarvester(telemetry.ConfigAPIKey(os.Getenv("NEW_RELIC_API_KEY"))) + h, err := telemetry.NewHarvester(telemetry.ConfigAPIKey(os.Getenv("NEW_RELIC_INSIGHTS_INSERT_API_KEY"))) if err != nil { fmt.Println(err) } diff --git a/cumulative/cumulative_test.go b/cumulative/cumulative_test.go index a3380d1..57a5a7e 100644 --- a/cumulative/cumulative_test.go +++ b/cumulative/cumulative_test.go @@ -17,7 +17,7 @@ import ( func Example() { h, err := telemetry.NewHarvester( - telemetry.ConfigAPIKey(os.Getenv("NEW_RELIC_API_KEY")), + telemetry.ConfigAPIKey(os.Getenv("NEW_RELIC_INSIGHTS_INSERT_API_KEY")), ) if err != nil { fmt.Println(err) diff --git a/examples/server/main.go b/examples/server/main.go index f6cbd7c..246eb5b 100644 --- a/examples/server/main.go +++ b/examples/server/main.go @@ -122,7 +122,7 @@ func main() { rand.Seed(time.Now().UnixNano()) var err error h, err = telemetry.NewHarvester( - telemetry.ConfigAPIKey(mustGetEnv("NEW_RELIC_API_KEY")), + telemetry.ConfigAPIKey(mustGetEnv("NEW_RELIC_INSIGHTS_INSERT_API_KEY")), telemetry.ConfigCommonAttributes(map[string]interface{}{ "app.name": "myServer", "host.name": "dev.server.com", diff --git a/telemetry/README.md b/telemetry/README.md index fded71f..8e85dab 100644 --- a/telemetry/README.md +++ b/telemetry/README.md @@ -11,7 +11,7 @@ the background. ```go harvester := telemetry.NewHarvester( - telemetry.ConfigAPIKey(os.Getenv("NEW_RELIC_API_KEY")), + telemetry.ConfigAPIKey(os.Getenv("NEW_RELIC_INSIGHTS_INSERT_API_KEY")), ) ``` diff --git a/telemetry/aggregated_metrics_test.go b/telemetry/aggregated_metrics_test.go index 952e881..6220127 100644 --- a/telemetry/aggregated_metrics_test.go +++ b/telemetry/aggregated_metrics_test.go @@ -78,19 +78,19 @@ func BenchmarkAggregatedMetric(b *testing.B) { } func ExampleMetricAggregator_Count() { - h, _ := NewHarvester(ConfigAPIKey(os.Getenv("NEW_RELIC_API_KEY"))) + h, _ := NewHarvester(ConfigAPIKey(os.Getenv("NEW_RELIC_INSIGHTS_INSERT_API_KEY"))) count := h.MetricAggregator().Count("myCount", map[string]interface{}{"zip": "zap"}) count.Increment() } func ExampleMetricAggregator_Gauge() { - h, _ := NewHarvester(ConfigAPIKey(os.Getenv("NEW_RELIC_API_KEY"))) + h, _ := NewHarvester(ConfigAPIKey(os.Getenv("NEW_RELIC_INSIGHTS_INSERT_API_KEY"))) gauge := h.MetricAggregator().Gauge("temperature", map[string]interface{}{"zip": "zap"}) gauge.Value(23.4) } func ExampleMetricAggregator_Summary() { - h, _ := NewHarvester(ConfigAPIKey(os.Getenv("NEW_RELIC_API_KEY"))) + h, _ := NewHarvester(ConfigAPIKey(os.Getenv("NEW_RELIC_INSIGHTS_INSERT_API_KEY"))) summary := h.MetricAggregator().Summary("mySummary", map[string]interface{}{"zip": "zap"}) summary.RecordDuration(3 * time.Second) } diff --git a/telemetry/config.go b/telemetry/config.go index 322c334..44619e1 100644 --- a/telemetry/config.go +++ b/telemetry/config.go @@ -13,7 +13,7 @@ import ( // Config customizes the behavior of a Harvester. type Config struct { - // APIKey is required. + // APIKey is required and refers to your New Relic Insights Insert API key. APIKey string // Client is the http.Client used for making requests. Client *http.Client @@ -47,7 +47,8 @@ type Config struct { ProductVersion string } -// ConfigAPIKey sets the Config's APIKey which is required. +// ConfigAPIKey sets the Config's APIKey which is required and refers to your +// New Relic Insights Insert API key. func ConfigAPIKey(key string) func(*Config) { return func(cfg *Config) { cfg.APIKey = key diff --git a/telemetry/example_test.go b/telemetry/example_test.go index 6d12745..7b94ebd 100644 --- a/telemetry/example_test.go +++ b/telemetry/example_test.go @@ -12,8 +12,8 @@ import ( func Example() { h, err := NewHarvester( - // APIKey is the only required field. - ConfigAPIKey(os.Getenv("NEW_RELIC_API_KEY")), + // APIKey is the only required field and refers to your New Relic Insights Insert API key. + ConfigAPIKey(os.Getenv("NEW_RELIC_INSIGHTS_INSERT_API_KEY")), ConfigCommonAttributes(map[string]interface{}{ "app.name": "myApplication", }), @@ -61,7 +61,7 @@ func Example() { func ExampleNewHarvester() { h, err := NewHarvester( - ConfigAPIKey(os.Getenv("NEW_RELIC_API_KEY")), + ConfigAPIKey(os.Getenv("NEW_RELIC_INSIGHTS_INSERT_API_KEY")), ) if err != nil { fmt.Println(err) @@ -78,7 +78,7 @@ func ExampleNewHarvester() { func ExampleHarvester_RecordMetric() { h, _ := NewHarvester( - ConfigAPIKey(os.Getenv("NEW_RELIC_API_KEY")), + ConfigAPIKey(os.Getenv("NEW_RELIC_INSIGHTS_INSERT_API_KEY")), ) start := time.Now() h.RecordMetric(Count{