nrstan

package
v3.14.1+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 20, 2021 License: Apache-2.0 Imports: 4 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package nrstan instruments https://github.com/nats-io/stan.go.

This package can be used to simplify instrumenting NATS Streaming subscribers. Currently due to the nature of the NATS Streaming framework we are limited to two integration points: `StartPublishSegment` for publishers, and `SubWrapper` for subscribers.

NATS Streaming subscribers

`nrstan.StreamingSubWrapper` can be used to wrap the function for STREAMING stan.Subscribe and stan.QueueSubscribe (https://godoc.org/github.com/nats-io/stan.go#Conn) If the `newrelic.Application` parameter is non-nil, it will create a `newrelic.Transaction` and end the transaction when the passed function is complete. Example:

sc, err := stan.Connect(clusterName, clientName)
if err != nil {
	t.Fatal("Couldn't connect to server", err)
}
defer sc.Close()
app := createTestApp(t)  // newrelic.Application
sc.Subscribe(subject, StreamingSubWrapper(app, myMessageHandler)

NATS Streaming publishers

You can use `nrnats.StartPublishSegment` from the `nrnats` package (https://godoc.org/github.com/newrelic/go-agent/_integrations/nrnats/#StartPublishSegment) to start an external segment when doing a streaming publish, which must be ended after publishing is complete. Example:

sc, err := stan.Connect(clusterName, clientName)
if err != nil {
	t.Fatal("Couldn't connect to server", err)
}
txn := currentTransaction()  // current newrelic.Transaction
seg := nrnats.StartPublishSegment(txn, sc.NatsConn(), subj)
sc.Publish(subj, []byte("Hello World"))
seg.End()

Full Publisher/Subscriber example: https://github.com/newrelic/go-agent/blob/master/_integrations/nrstan/examples/main.go

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func StreamingSubWrapper

func StreamingSubWrapper(app newrelic.Application, f func(msg *stan.Msg)) func(msg *stan.Msg)

StreamingSubWrapper can be used to wrap the function for STREAMING stan.Subscribe and stan.QueueSubscribe (https://godoc.org/github.com/nats-io/stan.go#Conn) If the `newrelic.Application` parameter is non-nil, it will create a `newrelic.Transaction` and end the transaction when the passed function is complete.

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL