Skip to content

Commit

Permalink
GROW-687 - Fix newrelic reporting (lavanet#383)
Browse files Browse the repository at this point in the history
* GROW-687 - Fix newrelic reporting

* Remove websocket

* add nil check
  • Loading branch information
nirtayeb authored Mar 30, 2023
1 parent cbfc30e commit a892c12
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 12 deletions.
20 changes: 20 additions & 0 deletions docs/static/openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29674,6 +29674,16 @@ paths:
in: query
required: false
type: boolean
- name: pagination.reverse
description: >-
reverse is set to true if results are to be returned in the
descending order.


Since: cosmos-sdk 0.43
in: query
required: false
type: boolean
tags:
- Query
'/lavanet/lava/epochstorage/fixated_params/{index}':
Expand Down Expand Up @@ -29933,6 +29943,16 @@ paths:
in: query
required: false
type: boolean
- name: pagination.reverse
description: >-
reverse is set to true if results are to be returned in the
descending order.


Since: cosmos-sdk 0.43
in: query
required: false
type: boolean
tags:
- Query
'/lavanet/lava/epochstorage/stake_storage/{index}':
Expand Down
4 changes: 2 additions & 2 deletions protocol/chainlib/jsonRPC.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,6 @@ func (apil *JsonRPCChainListener) Serve(ctx context.Context) {
app.Use(favicon.New())

app.Use("/ws/:dappId", func(c *fiber.Ctx) error {
apil.logger.LogStartTransaction("jsonRpc-WebSocket")
// IsWebSocketUpgrade returns true if the client
// requested upgrade to the WebSocket protocol.
if websocket.IsWebSocketUpgrade(c) {
Expand Down Expand Up @@ -291,7 +290,8 @@ func (apil *JsonRPCChainListener) Serve(ctx context.Context) {
app.Get("/:dappId/websocket", websocketCallbackWithDappID) // catching http://HOST:PORT/1/websocket requests.

app.Post("/:dappId/*", func(fiberCtx *fiber.Ctx) error {
apil.logger.LogStartTransaction("jsonRpc-http post")
endTx := apil.logger.LogStartTransaction("jsonRpc-http post")
defer endTx()
msgSeed := apil.logger.GetMessageSeed()
dappID := extractDappIDFromFiberContext(fiberCtx)
metricsData := metrics.NewRelayAnalytics(dappID, chainID, apiInterface)
Expand Down
6 changes: 4 additions & 2 deletions protocol/chainlib/rest.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,8 @@ func (apil *RestChainListener) Serve(ctx context.Context) {
apiInterface := apil.endpoint.ApiInterface
// Catch Post
app.Post("/:dappId/*", func(c *fiber.Ctx) error {
apil.logger.LogStartTransaction("rest-http")
endTx := apil.logger.LogStartTransaction("rest-http")
defer endTx()

msgSeed := apil.logger.GetMessageSeed()

Expand Down Expand Up @@ -255,7 +256,8 @@ func (apil *RestChainListener) Serve(ctx context.Context) {

// Catch the others
app.Use("/:dappId/*", func(c *fiber.Ctx) error {
apil.logger.LogStartTransaction("rest-http")
endTx := apil.logger.LogStartTransaction("rest-http")
defer endTx()
msgSeed := apil.logger.GetMessageSeed()

query := "?" + string(c.Request().URI().QueryString())
Expand Down
7 changes: 4 additions & 3 deletions protocol/chainlib/tendermintRPC.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,6 @@ func (apil *TendermintRpcChainListener) Serve(ctx context.Context) {
app.Use(favicon.New())

app.Use("/ws/:dappId", func(c *fiber.Ctx) error {
apil.logger.LogStartTransaction("tendermint-WebSocket")
// IsWebSocketUpgrade returns true if the client
// requested upgrade to the WebSocket protocol.
if websocket.IsWebSocketUpgrade(c) {
Expand Down Expand Up @@ -339,7 +338,8 @@ func (apil *TendermintRpcChainListener) Serve(ctx context.Context) {
app.Get("/:dappId/websocket", websocketCallbackWithDappID) // catching http://HOST:PORT/1/websocket requests.

app.Post("/:dappId/*", func(c *fiber.Ctx) error {
apil.logger.LogStartTransaction("tendermint-WebSocket")
endTx := apil.logger.LogStartTransaction("tendermint-WebSocket")
defer endTx()
msgSeed := apil.logger.GetMessageSeed()
dappID := extractDappIDFromFiberContext(c)
metricsData := metrics.NewRelayAnalytics(dappID, chainID, apiInterface)
Expand Down Expand Up @@ -375,7 +375,8 @@ func (apil *TendermintRpcChainListener) Serve(ctx context.Context) {
})

app.Get("/:dappId/*", func(c *fiber.Ctx) error {
apil.logger.LogStartTransaction("tendermint-WebSocket")
endTx := apil.logger.LogStartTransaction("tendermint-WebSocket")
defer endTx()

query := "?" + string(c.Request().URI().QueryString())
path := c.Params("*")
Expand Down
16 changes: 12 additions & 4 deletions protocol/common/rpcconsumerlogs.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,18 @@ func (pl *RPCConsumerLogs) LogRequestAndResponse(module string, hasError bool, m
utils.LavaFormatDebug(module, []utils.Attribute{{Key: "GUID", Value: msgSeed}, {Key: "request", Value: req}, {Key: "response", Value: parser.CapStringLen(resp)}, {Key: "method", Value: method}, {Key: "path", Value: path}, {Key: "HasError", Value: hasError}}...)
}

func (pl *RPCConsumerLogs) LogStartTransaction(name string) {
if pl.newRelicApplication != nil {
txn := pl.newRelicApplication.StartTransaction(name)
defer txn.End()
func (pl *RPCConsumerLogs) LogStartTransaction(name string) func() {
if pl.newRelicApplication == nil {
return func() {
}
}

tx := pl.newRelicApplication.StartTransaction(name)

return func() {
if tx != nil {
tx.End()
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion scripts/setup_providers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -162,4 +162,4 @@ screen -d -m -S portals bash -c "source ~/.bashrc; lavad rpcconsumer \
$EXTRA_PORTAL_FLAGS --geolocation 1 --log_level debug --from user1 2>&1 | tee $LOGS_DIR/PORTAL.log" && sleep 0.25

echo "--- setting up screens done ---"
screen -ls
screen -ls

0 comments on commit a892c12

Please sign in to comment.