Skip to content

Commit

Permalink
feat(integration): add logging to improve observability
Browse files Browse the repository at this point in the history
Add logging statements to the codebase to improve observability. In `grpc.go`, add a log statement to the `GetBalance` function to log when the function is called. In `utils.go`, add a log statement to the `setHeaderFromContext` function to log the key and value of the trace context.
  • Loading branch information
shumkovdenis committed May 10, 2023
1 parent f4acb02 commit 91912af
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
2 changes: 2 additions & 0 deletions services/integration/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main
import (
"context"
"fmt"
"log"
"net/http"

"github.com/bufbuild/connect-go"
Expand Down Expand Up @@ -54,6 +55,7 @@ func (s *GRPCServer) GetBalance(
ctx context.Context,
req *connect.Request[integration.GetBalanceRequest],
) (*connect.Response[integration.GetBalanceResponse], error) {
log.Println("get balance")
reqBalance := connect.NewRequest(&integration.GetBalanceRequest{})

resBalance, err := s.integrationService.GetBalance(ctx, reqBalance)
Expand Down
1 change: 1 addition & 0 deletions services/integration/helpers/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (

func setHeaderFromContext(key traceContextKey, header http.Header, ctx context.Context) {
value := ExtractTrace(ctx, key)
log.Println("set header from context", key, value)
if value != "" {
header.Set(string(key), value)
}
Expand Down

0 comments on commit 91912af

Please sign in to comment.