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 #15 from newrelic/rabolofia/infinite-tracing
Browse files Browse the repository at this point in the history
Make it easier to use Infinite Tracing.
  • Loading branch information
purple4reina authored Jun 12, 2020
2 parents bfa99a8 + 2f7218d commit bfbcaea
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 1 deletion.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
## ChangeLog

## 0.3.0

* 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
Expand Down
14 changes: 13 additions & 1 deletion telemetry/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,18 @@ 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
// ProductVersion is added to the User-Agent header. eg. "0.1.0".
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) {
Expand Down Expand Up @@ -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) {
Expand Down
21 changes: 21 additions & 0 deletions telemetry/example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
})
}

0 comments on commit bfbcaea

Please sign in to comment.