Skip to content
This repository has been archived by the owner on Jul 12, 2024. It is now read-only.

Commit

Permalink
Merge pull request #5 from newrelic/eheinlein-api-key-docs
Browse files Browse the repository at this point in the history
Improve docs around API key meaning
  • Loading branch information
newrelic-eheinlein authored Jan 16, 2020
2 parents 7fc7e6f + 8beb7b7 commit 790ff85
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 15 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion cumulative/cumulative_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion examples/server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion telemetry/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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")),
)
```

Expand Down
6 changes: 3 additions & 3 deletions telemetry/aggregated_metrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
5 changes: 3 additions & 2 deletions telemetry/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions telemetry/example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
}),
Expand Down Expand Up @@ -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)
Expand All @@ -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{
Expand Down

0 comments on commit 790ff85

Please sign in to comment.