2.14.0
New Features
Added support for a new segment type,
MessageProducerSegment
, to be used to track time spent adding messages to message queuing systems like RabbitMQ or Kafka.seg := &newrelic.MessageProducerSegment{StartTime: newrelic.StartSegmentNow(txn),Library: "RabbitMQ",DestinationType: newrelic.MessageExchange,DestinationName: "myExchange",}// add message to queue hereseg.End()Added new attribute constants for use with message consumer transactions. These attributes can be used to add more detail to a transaction that tracks time spent consuming a message off a message queuing system like RabbitMQ or Kafka. They can be added using
txn.AddAttribute
.// The routing key of the consumed message.txn.AddAttribute(newrelic.AttributeMessageRoutingKey, "myRoutingKey")// The name of the queue the message was consumed from.txn.AddAttribute(newrelic.AttributeMessageQueueName, "myQueueName")// The type of exchange used for the consumed message (direct, fanout,// topic, or headers).txn.AddAttribute(newrelic.AttributeMessageExchangeType, "myExchangeType")// The callback queue used in RPC configurations.txn.AddAttribute(newrelic.AttributeMessageReplyTo, "myReplyTo")// The application-generated identifier used in RPC configurations.txn.AddAttribute(newrelic.AttributeMessageCorrelationID, "myCorrelationID")It is recommended that at most one message is consumed per transaction.
Added support for Go 1.13's Error wrapping.
Transaction.NoticeError
now uses Unwrap recursively to identify the error's cause (the deepest wrapped error) when generating the error's class field. This functionality will help group your errors usefully.For example, when using Go 1.13, the following code:
type socketError struct{}func (e socketError) Error() string { return "socket error" }func gamma() error { return socketError{} }func beta() error { return fmt.Errorf("problem in beta: %w", gamma()) }func alpha() error { return fmt.Errorf("problem in alpha: %w", beta()) }func execute(txn newrelic.Transaction) {err := alpha()txn.NoticeError(err)}captures an error with message
"problem in alpha: problem in beta: socket error"
and class"main.socketError"
. Previously, the class was recorded as"*fmt.wrapError"
.A
Stack
field has been added to Error, which can be assigned using the new NewStackTrace function. This allows your error stack trace to show where the error happened, rather than the location of theNoticeError
call.Transaction.NoticeError
not only checks for a stack trace (using StackTracer) in the error parameter, but in the error's cause as well. This means that you can create an Error where your error occurred, wrap it multiple times to add information, notice it withNoticeError
, and still have a useful stack trace. Take a look!func gamma() error {return newrelic.Error{Message: "something went very wrong",Class: "socketError",Stack: newrelic.NewStackTrace(),}}func beta() error { return fmt.Errorf("problem in beta: %w", gamma()) }func alpha() error { return fmt.Errorf("problem in alpha: %w", beta()) }func execute(txn newrelic.Transaction) {err := alpha()txn.NoticeError(err)}In this example, the topmost stack trace frame recorded is
"gamma"
, rather than"execute"
.Added support for configuring a maximum number of transaction events per minute to be sent to New Relic. It can be configured as follows:
config := newrelic.NewConfig("Application Name", os.Getenv("NEW_RELIC_LICENSE_KEY"))config.TransactionEvents.MaxSamplesStored = 100- For additional configuration information, see our documentation
Miscellaneous
Updated the
nrmicro
package to use the new segment typeMessageProducerSegment
and the new attribute constants:nrmicro.ClientWrapper
now usesnewrelic.MessageProducerSegment
s instead ofnewrelic.ExternalSegment
s for calls toClient.Publish
.nrmicro.SubscriberWrapper
updates transaction names and adds the attributemessage.routingKey
.
Updated the
nrnats
andnrstan
packages to use the new segment typeMessageProducerSegment
and the new attribute constants:nrnats.StartPublishSegment
now starts and returns anewrelic.MessageProducerSegment
type.nrnats.SubWrapper
andnrstan.StreamingSubWrapper
updates transaction names and adds the attributesmessage.routingKey
,message.queueName
, andmessage.replyTo
.