Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add OpenTelemetry tracing with grpc interceptors #2954

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion common/cauthdsl/policy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ func TestNewPolicyErrorCase(t *testing.T) {
pol1, msg1, err1 := provider.NewPolicy([]byte{0})
require.Nil(t, pol1)
require.Nil(t, msg1)
require.EqualError(t, err1, "Error unmarshalling to SignaturePolicy: proto: common.SignaturePolicyEnvelope: illegal tag 0 (wire type 0)")
require.EqualError(t, err1, "Error unmarshalling to SignaturePolicy: proto: cannot parse invalid wire-format data")

sigPolicy2 := &cb.SignaturePolicyEnvelope{Version: -1}
data2 := marshalOrPanic(sigPolicy2)
Expand Down
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