From 227d628a3a49d2f8d7dfc6ca05e68fd8d91ff7e2 Mon Sep 17 00:00:00 2001 From: Rey Abolofia Date: Fri, 12 Jun 2020 14:04:52 -0700 Subject: [PATCH 1/2] Make it easier to use Infinite Tracing. --- CHANGELOG.md | 3 +++ telemetry/config.go | 14 +++++++++++++- telemetry/example_test.go | 21 +++++++++++++++++++++ 3 files changed, 37 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c60a59d..a03cb6b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ ## ChangeLog +* Added `ConfigSpansURLOverride` to facilitate setting the Trace Observer URL + for Infinite Tracing on the New Relic Edge. + ## 0.2.0 * The SDK will now check metrics for infinity and NaN. Metrics with invalid diff --git a/telemetry/config.go b/telemetry/config.go index 44619e1..a075687 100644 --- a/telemetry/config.go +++ b/telemetry/config.go @@ -40,6 +40,10 @@ type Config struct { // MetricsURLOverride overrides the metrics endpoint if not not empty. MetricsURLOverride string // SpansURLOverride overrides the spans endpoint if not not empty. + // + // To enable Infinite Tracing on the New Relic Edge, set this field to your + // Trace Observer URL. See + // https://docs.newrelic.com/docs/understand-dependencies/distributed-tracing/enable-configure/enable-distributed-tracing SpansURLOverride string // Product is added to the User-Agent header. eg. "NewRelic-Go-OpenCensus" Product string @@ -47,7 +51,7 @@ type Config struct { ProductVersion string } -// ConfigAPIKey sets the Config's APIKey which is required and refers to your +// 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) { @@ -108,6 +112,14 @@ func ConfigBasicAuditLogger(w io.Writer) func(*Config) { } } +// ConfigSpansURLOverride sets the Config's SpansURLOverride field which +// overrides the spans endpoint if not not empty. +func ConfigSpansURLOverride(url string) func(*Config) { + return func(cfg *Config) { + cfg.SpansURLOverride = url + } +} + // configTesting is the config function to be used when testing. It sets the // APIKey but disables the harvest goroutine. func configTesting(cfg *Config) { diff --git a/telemetry/example_test.go b/telemetry/example_test.go index 7b94ebd..63dab39 100644 --- a/telemetry/example_test.go +++ b/telemetry/example_test.go @@ -89,3 +89,24 @@ func ExampleHarvester_RecordMetric() { Interval: 5 * time.Second, }) } + +func ExampleConfigSpansURLOverride() { + h, _ := NewHarvester( + ConfigAPIKey(os.Getenv("NEW_RELIC_INSIGHTS_INSERT_API_KEY")), + // Use ConfigSpansURLOverride to enable Infinite Tracing on the New + // Relic Edge by passing it your Trace Observer URL, including scheme + // and path. + ConfigSpansURLOverride("https://nr-internal.aws-us-east-1.tracing.edge.nr-data.net/trace/v1"), + ) + h.RecordSpan(Span{ + ID: "12345", + TraceID: "67890", + Name: "purple-span", + Timestamp: time.Now(), + Duration: time.Second, + ServiceName: "ExampleApplication", + Attributes: map[string]interface{}{ + "color": "purple", + }, + }) +} From 2f7218df0ca5baa572a0e3fae622fc5b23641d5d Mon Sep 17 00:00:00 2001 From: Rey Abolofia Date: Fri, 12 Jun 2020 16:01:19 -0700 Subject: [PATCH 2/2] Update changelog. --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a03cb6b..8c901c7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ ## ChangeLog +## 0.3.0 + * Added `ConfigSpansURLOverride` to facilitate setting the Trace Observer URL for Infinite Tracing on the New Relic Edge.