-
Notifications
You must be signed in to change notification settings - Fork 296
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Automatically instrument and collect distributed traces on AMQP/RabbitMQ code with the New Relic Go agent.
- Loading branch information
Showing
2 changed files
with
50 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
module github.com/newrelic/go-agent/v3/integrations/nramqp | ||
|
||
go 1.21.0 | ||
|
||
require ( | ||
github.com/newrelic/go-agent/v3 v3.24.1 | ||
github.com/rabbitmq/amqp091-go v1.8.1 | ||
) | ||
|
||
require ( | ||
github.com/golang/protobuf v1.5.3 // indirect | ||
golang.org/x/net v0.8.0 // indirect | ||
golang.org/x/sys v0.6.0 // indirect | ||
golang.org/x/text v0.8.0 // indirect | ||
google.golang.org/genproto v0.0.0-20230110181048-76db0878b65f // indirect | ||
google.golang.org/grpc v1.54.0 // indirect | ||
google.golang.org/protobuf v1.28.1 // indirect | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package nramqp | ||
|
||
import ( | ||
"context" | ||
|
||
amqp "github.com/rabbitmq/amqp091-go" | ||
|
||
"github.com/newrelic/go-agent/v3/newrelic" | ||
) | ||
|
||
type Channel struct { | ||
amqpChan amqp.Channel | ||
} | ||
|
||
func (ch *Channel) ConsumeWithContext(ctx context.Context, queue, consumer string, autoAck, exclusive, noLocal, noWait bool, args amqp.Table) { | ||
txn := newrelic.FromContext(ctx) | ||
if txn != nil { | ||
|
||
} | ||
} | ||
|
||
func (ch *Channel) PublishWithContext(ctx context.Context, exchange, key string, mandatory, immediate bool, msg amqp.Publishing) error { | ||
txn := newrelic.FromContext(ctx) | ||
if txn != nil { | ||
txn.InsertDistributedTraceHeaders() | ||
|
||
publishSegment := txn.StartSegment("MessageBroker/RabbitMQ/Channel/Publish") | ||
defer publishSegment.End() | ||
} | ||
|
||
return ch.amqpChan.PublishWithContext(ctx, exchange, key, mandatory, immediate, msg) | ||
} |