Skip to content

Commit

Permalink
Add OpenTelemetry interceptors to capture traces from gRPC communicat…
Browse files Browse the repository at this point in the history
…ions

Signed-off-by: Antoine Toulme <[email protected]>
  • Loading branch information
atoulme committed Jun 24, 2022
1 parent 6e5e693 commit 4c2074d
Show file tree
Hide file tree
Showing 166 changed files with 24,554 additions and 597 deletions.
189 changes: 189 additions & 0 deletions common/grpctracing/fakes/echo_service.go

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

28 changes: 28 additions & 0 deletions common/grpctracing/grpctracing_suite_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
Copyright IBM Corp. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/

package grpctracing_test

import (
"testing"

"github.com/hyperledger/fabric/common/grpctracing/testpb"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)

//go:generate protoc --proto_path=testpb --go_out=plugins=grpc,paths=source_relative:testpb testpb/echo.proto

func TestGrpctracing(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "Grpctracing Suite")
}

//go:generate counterfeiter -o fakes/echo_service.go --fake-name EchoServiceServer . echoServiceServer

type echoServiceServer interface {
testpb.EchoServiceServer
}
20 changes: 20 additions & 0 deletions common/grpctracing/interceptor.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
Copyright IBM Corp. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/

package grpctracing

import (
"go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc"
"google.golang.org/grpc"
)

func UnaryServerInterceptor() grpc.UnaryServerInterceptor {
return otelgrpc.UnaryServerInterceptor()
}

func StreamServerInterceptor() grpc.StreamServerInterceptor {
return otelgrpc.StreamServerInterceptor()
}
Loading

0 comments on commit 4c2074d

Please sign in to comment.