Skip to content

Commit d5b21f7

Browse files
Tempo: Fix grpc streaming support over pdc-agent (grafana#89883)
* Tempo: Fix grpc streaming support over pdc-agent * Fix a spelling error and formatting * Ignore lint issue for reasons listed in source code comment --------- Co-authored-by: Joey Tawadrous <[email protected]>
1 parent 12a5583 commit d5b21f7

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

pkg/tsdb/tempo/grpc.go

+22-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,28 @@ func newGrpcClient(ctx context.Context, settings backend.DataSourceInstanceSetti
4848
if err != nil {
4949
return nil, fmt.Errorf("error getting dial options: %w", err)
5050
}
51-
clientConn, err := grpc.NewClient(onlyHost, dialOpts...)
51+
52+
// grpc.Dial() is deprecated in favor of grpc.NewClient(), but grpc.NewClient() changed the default resolver to dns from passthrough.
53+
// This is a problem because the getDialOpts() function appends a custom dialer to the dial options to support Grafana Cloud PDC.
54+
//
55+
// See the following quote from the grpc package documentation:
56+
// One subtle difference between NewClient and Dial and DialContext is that the
57+
// former uses "dns" as the default name resolver, while the latter use
58+
// "passthrough" for backward compatibility. This distinction should not matter
59+
// to most users, but could matter to legacy users that specify a custom dialer
60+
// and expect it to receive the target string directly.
61+
// https://github.com/grpc/grpc-go/blob/fa274d77904729c2893111ac292048d56dcf0bb1/clientconn.go#L209
62+
//
63+
// Unfortunately, the passthrough resolver isn't exported by the grpc package, so we can't use it.
64+
// The options are to continue using grpc.Dial() or implement a custom resolver.
65+
// Since the go-grpc package maintainers intend to continue supporting grpc.Dial() through the 1.x series,
66+
// we'll continue using grpc.Dial() until we have a compelling reason or bandwidth to implement the custom resolver.
67+
// Reference: https://github.com/grpc/grpc-go/blob/f199062ef31ddda54152e1ca5e3d15fb63903dc3/clientconn.go#L204
68+
//
69+
// See this issue for more information: https://github.com/grpc/grpc-go/issues/7091
70+
// Ignore the lint check as this fails the build and for the reasons above.
71+
// nolint:staticcheck
72+
clientConn, err := grpc.Dial(onlyHost, dialOpts...)
5273
if err != nil {
5374
logger.Error("Error dialing gRPC client", "error", err, "URL", settings.URL, "function", logEntrypoint())
5475
return nil, err

0 commit comments

Comments
 (0)