contrib/connectrpc.com/connect

contrib/connectrpc.com/connect

Those integration are enabled by having the following import in the project’s orchestrion.tool.go file:

import (
	_ "github.com/DataDog/orchestrion"

	_ "github.com/DataDog/dd-trace-go/contrib/connectrpc.com/connect/v2" // integration
	//...
)

Connect is an RPC framework built on Protocol Buffers and net/http.

Details & Caveats

  • Clients generated by protoc-gen-connect-go v1.13.0 or later are instrumented through connect.WithClientOptions. Versions v1.7.0 to v1.12.x emit that call only for methods with an idempotency_level option, and older versions never emit it. Direct connect.NewClient calls need a connect.WithClientOptions(...) argument, or connecttrace.NewClientInterceptor() added manually.
  • Handler constructors called with explicit type arguments, such as connect.NewUnaryHandler[Req, Res](...), are not matched: let Go infer the type arguments, or add the interceptor manually.
  • The interceptor is appended last, so it is the innermost one: RPCs rejected by earlier interceptors, or before the interceptor chain runs (for example while decoding a unary request), produce no server span.
  • Handlers created by helper libraries such as grpchealth and grpcreflect are instrumented too.

Client

Advice
Replace the expression using the template:
// Using the following synthetic imports:
import (
	connect "connectrpc.com/connect"
	connecttrace "github.com/DataDog/dd-trace-go/contrib/connectrpc.com/connect/v2"
)
connect.WithClientOptions({{ . }}, connect.WithInterceptors(connecttrace.NewClientInterceptor()))

Handler

Advice
Replace the expression using the template:
// Using the following synthetic imports:
import (
	connect "connectrpc.com/connect"
	connecttrace "github.com/DataDog/dd-trace-go/contrib/connectrpc.com/connect/v2"
)
{{- if .AST.Ellipsis -}}
{{ .AST.Fun }}({{ index .AST.Args 0 }}, {{ index .AST.Args 1 }}, connect.WithHandlerOptions({{ index .AST.Args 2 }}...), connect.WithInterceptors(connecttrace.NewServerInterceptor()))
{{- else -}}
{{ .AST.Fun }}({{ range .AST.Args }}{{ . }}, {{ end }}connect.WithInterceptors(connecttrace.NewServerInterceptor()))
{{- end -}}