Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
123c121
initial grpc work
ribice Dec 25, 2024
0712d4c
initial grpc work
ribice Dec 25, 2024
cc9547c
add grpc integration
ribice Dec 27, 2024
a904dfd
update grpc dependencies
ribice Dec 27, 2024
2f3c7c5
Update grpc example structure
ribice Dec 27, 2024
77a6c95
fix tests
ribice Dec 27, 2024
16ee674
add span origin
ribice Dec 27, 2024
2f47b43
downgrade grpc dependency version
ribice Dec 27, 2024
8c75a66
update changelog
ribice Dec 27, 2024
dda5723
Merge branch 'master' into grpc-interceptor
ribice Dec 30, 2024
92c1a30
Merge remote-tracking branch 'origin/master' into grpc-interceptor
giortzisg Apr 17, 2025
b88a00c
Merge branch 'master' into grpc-interceptor
giortzisg Apr 17, 2025
3582c47
Merge branch 'master' into grpc-interceptor
giortzisg Apr 28, 2025
c7616c7
chore: remove operation name option from server
giortzisg Apr 29, 2025
2142591
chore: improve test coverage
giortzisg May 2, 2025
8b79e6e
remove error capture
giortzisg May 6, 2025
0ae4e61
remove error capture from server
giortzisg May 6, 2025
9e51213
update client examples
giortzisg May 6, 2025
6b3eefb
update README
giortzisg May 6, 2025
8404fc4
update go and sdk version
giortzisg Mar 30, 2026
1d90a1e
fix rpc span attributes
giortzisg Mar 30, 2026
f8a41d9
Merge remote-tracking branch 'origin/master' into grpc-interceptor
giortzisg Mar 30, 2026
0933046
mod tidy
giortzisg Mar 30, 2026
7912c13
bump google.golang.org/grpc to latest
giortzisg Mar 30, 2026
8007d7f
fix tests
giortzisg Mar 30, 2026
9cc7d0d
revert logrus README change and change timeout
giortzisg Mar 30, 2026
ec00d57
go mod tidy
giortzisg Mar 30, 2026
1bc0682
update README and example
giortzisg Mar 31, 2026
dbdad59
add span origin & handle empty stream case
giortzisg Mar 31, 2026
7e5b061
fix span attributes
giortzisg Mar 31, 2026
b0de8ae
simplify tests
giortzisg Mar 31, 2026
d9ccd34
misc fixes
giortzisg Mar 31, 2026
8844c99
fix trace continuation
giortzisg Mar 31, 2026
6e55ff4
filter grpc sensitive metadata
giortzisg Mar 31, 2026
81528b4
fix(grpc): Use 2s default timeout consistent with other integrations
cursoragent Mar 31, 2026
c17453f
add default flush timeout
giortzisg Apr 1, 2026
aeae8b2
fix import cycle
giortzisg Apr 1, 2026
718d221
fix examples
giortzisg Apr 1, 2026
48d2795
remove SetDefaults test
giortzisg Apr 1, 2026
b7de787
extend client tests
giortzisg Apr 1, 2026
43d773b
add MergeBaggage helper
giortzisg Apr 1, 2026
e19e1ad
ref client & server
giortzisg Apr 1, 2026
5e7b9c9
fix: MergeBaggage keeps sentry baggage when incoming is malformed
giortzisg Apr 1, 2026
970151e
fix(grpc): Flush events when WaitForDelivery is true
cursoragent Apr 1, 2026
4e9ad6b
Merge branch 'master' into grpc-interceptor
giortzisg Apr 1, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .craft.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ targets:
- name: github
tagPrefix: gin/v
tagOnly: true
- name: github
tagPrefix: grpc/v
tagOnly: true
- name: github
tagPrefix: iris/v
tagOnly: true
Expand Down
119 changes: 119 additions & 0 deletions _examples/grpc/client/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
package main

import (
"context"
"fmt"
"io"
"log"
"time"

"grpcdemo/cmd/server/examplepb"

"github.com/getsentry/sentry-go"
sentrygrpc "github.com/getsentry/sentry-go/grpc"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
"google.golang.org/grpc/metadata"
)

const grpcServerAddress = "localhost:50051"

func main() {
// Initialize Sentry
err := sentry.Init(sentry.ClientOptions{
Dsn: "",
TracesSampleRate: 1.0,
})
if err != nil {
log.Fatalf("sentry.Init: %s", err)
}
defer sentry.Flush(2 * time.Second)

// Create a connection to the gRPC server with Sentry interceptors
conn, err := grpc.NewClient(
grpcServerAddress,
grpc.WithTransportCredentials(insecure.NewCredentials()), // Use TLS in production
grpc.WithUnaryInterceptor(sentrygrpc.UnaryClientInterceptor()),
grpc.WithStreamInterceptor(sentrygrpc.StreamClientInterceptor()),
)
if err != nil {
log.Fatalf("Failed to connect to gRPC server: %s", err)
}
defer conn.Close()

// Create a client for the ExampleService
client := examplepb.NewExampleServiceClient(conn)

// Perform Unary call
fmt.Println("Performing Unary Call:")
unaryExample(client)

// Perform Streaming call
fmt.Println("\nPerforming Streaming Call:")
streamExample(client)
}

func unaryExample(client examplepb.ExampleServiceClient) {
ctx := context.Background()

// Add metadata to the context
ctx = metadata.NewOutgoingContext(ctx, metadata.Pairs(
"custom-header", "value",
))

req := &examplepb.ExampleRequest{
Message: "Hello, server!", // Change to "error" to simulate an error
}

res, err := client.UnaryExample(ctx, req)
if err != nil {
fmt.Printf("Unary Call Error: %v\n", err)
sentry.CaptureException(err)
return
}

fmt.Printf("Unary Response: %s\n", res.Message)
}

func streamExample(client examplepb.ExampleServiceClient) {
ctx := context.Background()

// Add metadata to the context
ctx = metadata.NewOutgoingContext(ctx, metadata.Pairs(
"streaming-header", "stream-value",
))

stream, err := client.StreamExample(ctx)
if err != nil {
fmt.Printf("Failed to establish stream: %v\n", err)
sentry.CaptureException(err)
return
}

// Send multiple messages in the stream
messages := []string{"Message 1", "Message 2", "error", "Message 4"}
for _, msg := range messages {
err := stream.Send(&examplepb.ExampleRequest{Message: msg})
if err != nil {
fmt.Printf("Stream Send Error: %v\n", err)
sentry.CaptureException(err)
return
}
}

// Close the stream for sending
stream.CloseSend()

// Receive responses from the server
for {
res, err := stream.Recv()
if err != nil {
if err != io.EOF {
fmt.Printf("Stream Recv Error: %v\n", err)
sentry.CaptureException(err)
}
break
}
fmt.Printf("Stream Response: %s\n", res.Message)
}
}
21 changes: 21 additions & 0 deletions _examples/grpc/server/example.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
syntax = "proto3";

package main;

option go_package = "github.com/your-username/your-repo/examplepb;examplepb";

// ExampleService defines the gRPC service.
service ExampleService {
rpc UnaryExample(ExampleRequest) returns (ExampleResponse);
rpc StreamExample(stream ExampleRequest) returns (stream ExampleResponse);
}

// ExampleRequest is the request message.
message ExampleRequest {
string message = 1;
}

// ExampleResponse is the response message.
message ExampleResponse {
string message = 1;
}
191 changes: 191 additions & 0 deletions _examples/grpc/server/examplepb/example.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading