From 2809213245212d684b199d1f36bec5e8ee54a66b Mon Sep 17 00:00:00 2001 From: Rich Vanderwal Date: Wed, 27 Jan 2021 13:18:31 -0800 Subject: [PATCH 1/2] add span.kind advice in example --- README.md | 30 +++++++++++++++++++++++------- examples/simple/main.go | 3 ++- 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index e9f77aa..2f37923 100644 --- a/README.md +++ b/README.md @@ -32,9 +32,10 @@ Here’s what to do to switch out the text-based exporter defined in the Go Open There are three steps to get it reporting to New Relic: -1. replace an import statement +1. replace an import statement, and add some imports 1. instantiate a ```newrelic``` exporter with some configuration options -1. give the exporter time to report to New Relic. +1. set the span.kind for a better UI experience in New Relic + Full source of this modified sample application is available in examples/simple/main.go. @@ -50,6 +51,13 @@ Full source of this modified sample application is available in examples/simple/ "github.com/newrelic/opentelemetry-exporter-go/newrelic" ``` + You'll also need to add some imports, if they're missing: + ``` + "os" + "fmt" + "github.com/newrelic/newrelic-telemetry-sdk-go/telemetry" + ``` + 2. Rather than instantiate a ```stdout``` exporter, instantiate a ```newrelic``` exporter. Replace this: @@ -97,11 +105,19 @@ Full source of this modified sample application is available in examples/simple/ * Once we have the context (```ctx```), we defer the Shutdown function so the exporter has a chance to flush any accumulated data to the New Relic [Metrics and Traces](https://newrelic.com/platform/telemetry-data-101) endpoints. -3. You'll need to add some imports to the top of the file. +3. This example generates a parent span and a child span. For the parent, set + the kind of span to "server" to get the best experience in the New Relic UI. + + Change: + ``` - "os" - "fmt" - "github.com/newrelic/newrelic-telemetry-sdk-go/telemetry" + ctx, span = tracer.Start(ctx, "operation") + ``` + ...to: + + ``` + ctx, span = tracer.Start(ctx, "operation", + trace.WithSpanKind(trace.SpanKindServer)) ``` You’re now set! If you’re not using go mod, you’ll need to download the exporter using the go get command: @@ -198,7 +214,7 @@ To [all contributors](), we thank you! Without your contr opentelemetry-exporter-go is licensed under the [Apache 2.0](http://apache.org/licenses/LICENSE-2.0.txt) License. -## **imitations** +## **Limitations** The New Relic Telemetry APIs are rate limited. Please reference the documentation for [New Relic Metrics diff --git a/examples/simple/main.go b/examples/simple/main.go index d16aaac..dfb093e 100644 --- a/examples/simple/main.go +++ b/examples/simple/main.go @@ -110,7 +110,8 @@ func main() { func(ctx context.Context) { var span trace.Span - ctx, span = tracer.Start(ctx, "operation") + ctx, span = tracer.Start(ctx, "operation", + trace.WithSpanKind(trace.SpanKindServer)) defer span.End() span.AddEvent("Nice operation!", trace.WithAttributes(label.Int("bogons", 100))) From 372dbf09818e447e93181550a75455832cb0b784 Mon Sep 17 00:00:00 2001 From: Rich Vanderwal Date: Wed, 27 Jan 2021 13:31:58 -0800 Subject: [PATCH 2/2] SpanKind addition --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b1c0847..d1854e2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## [Unreleased] +### Changed + +- Added SpanKind to Getting Started guide and simple sample application in order + to provide a better New Relic UI experience. + ## [0.15.1] - 2021-01-26 ### Changed