Skip to content

Commit

Permalink
Fixed for grpc method type
Browse files Browse the repository at this point in the history
  • Loading branch information
aayush-ap committed Jan 15, 2024
1 parent b54ab9b commit 1a6ea2c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion v3/integrations/nrgrpc/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
// protobuf v1.3.0 is the earliest version using modules, we use v1.3.1
// because all dependencies were removed in this version.
github.com/golang/protobuf v1.5.3
github.com/newrelic/go-agent/v3 v3.28.1
github.com/newrelic/go-agent/v3 v3.29.0
github.com/newrelic/go-agent/v3/integrations/nrsecurityagent v1.1.0
// v1.15.0 is the earliest version of grpc using modules.
google.golang.org/grpc v1.56.3
Expand Down
18 changes: 13 additions & 5 deletions v3/integrations/nrgrpc/nrgrpc_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import (
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/metadata"
"google.golang.org/grpc/peer"
"google.golang.org/grpc/status"
protoV2 "google.golang.org/protobuf/proto"
)
Expand All @@ -62,13 +63,20 @@ func startTransaction(ctx context.Context, app *newrelic.Application, fullMethod

target := hdrs.Get(":authority")
url := getURL(method, target)
transport := newrelic.TransportHTTP

p, ok := peer.FromContext(ctx)
if ok && p != nil && p.AuthInfo != nil && p.AuthInfo.AuthType() == "tls" {
transport = newrelic.TransportHTTPS
}

webReq := newrelic.WebRequest{
Header: hdrs,
URL: url,
Method: method,
Transport: newrelic.TransportHTTP,
Type: "gRPC",
Header: hdrs,
URL: url,
Method: method,
Transport: transport,
Type: "gRPC",
ServerName: target,
}
txn := app.StartTransaction(method)
txn.SetWebRequest(webReq)
Expand Down

0 comments on commit 1a6ea2c

Please sign in to comment.