Skip to content
This repository has been archived by the owner on Jan 22, 2022. It is now read-only.

Set spankind #54

Merged
merged 3 commits into from
Mar 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.17.0] - 2021-03-02

### Changed
Expand Down
30 changes: 23 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand All @@ -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:

Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -198,7 +214,7 @@ To [all contributors](<LINK TO 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
Expand Down
3 changes: 2 additions & 1 deletion examples/simple/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,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)))
Expand Down