// Code generated by gtrace. DO NOT EDIT.

package gtrace

import (
	"context"

	"github.com/ydb-platform/ydb-go-sdk/v3/trace"
)

// driverComposeOptions is a holder of options
type driverComposeOptions struct {
	panicCallback func(e interface{})
}

// DriverOption specified Driver compose option
// Internals: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#internals
type DriverComposeOption func(o *driverComposeOptions)

// WithDriverPanicCallback specified behavior on panic
// Internals: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#internals
func WithDriverPanicCallback(cb func(e interface{})) DriverComposeOption {
	return func(o *driverComposeOptions) {
		o.panicCallback = cb
	}
}

// Compose returns a new Driver which has functional fields composed both from lhs and rhs.
// Internals: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#internals
func Compose(lhs *trace.Driver, rhs *trace.Driver, opts ...DriverComposeOption) *trace.Driver {
	if lhs == nil {
		return rhs
	}
	var ret trace.Driver
	options := driverComposeOptions{}
	for _, opt := range opts {
		if opt != nil {
			opt(&options)
		}
	}
	{
		h1 := lhs.OnInit
		h2 := rhs.OnInit
		ret.OnInit = func(d trace.DriverInitStartInfo) func(trace.DriverInitDoneInfo) {
			if options.panicCallback != nil {
				defer func() {
					if e := recover(); e != nil {
						options.panicCallback(e)
					}
				}()
			}
			var r, r1 func(trace.DriverInitDoneInfo)
			if h1 != nil {
				r = h1(d)
			}
			if h2 != nil {
				r1 = h2(d)
			}
			return func(d trace.DriverInitDoneInfo) {
				if options.panicCallback != nil {
					defer func() {
						if e := recover(); e != nil {
							options.panicCallback(e)
						}
					}()
				}
				if r != nil {
					r(d)
				}
				if r1 != nil {
					r1(d)
				}
			}
		}
	}
	{
		h1 := lhs.OnWith
		h2 := rhs.OnWith
		ret.OnWith = func(d trace.DriverWithStartInfo) func(trace.DriverWithDoneInfo) {
			if options.panicCallback != nil {
				defer func() {
					if e := recover(); e != nil {
						options.panicCallback(e)
					}
				}()
			}
			var r, r1 func(trace.DriverWithDoneInfo)
			if h1 != nil {
				r = h1(d)
			}
			if h2 != nil {
				r1 = h2(d)
			}
			return func(d trace.DriverWithDoneInfo) {
				if options.panicCallback != nil {
					defer func() {
						if e := recover(); e != nil {
							options.panicCallback(e)
						}
					}()
				}
				if r != nil {
					r(d)
				}
				if r1 != nil {
					r1(d)
				}
			}
		}
	}
	{
		h1 := lhs.OnClose
		h2 := rhs.OnClose
		ret.OnClose = func(d trace.DriverCloseStartInfo) func(trace.DriverCloseDoneInfo) {
			if options.panicCallback != nil {
				defer func() {
					if e := recover(); e != nil {
						options.panicCallback(e)
					}
				}()
			}
			var r, r1 func(trace.DriverCloseDoneInfo)
			if h1 != nil {
				r = h1(d)
			}
			if h2 != nil {
				r1 = h2(d)
			}
			return func(d trace.DriverCloseDoneInfo) {
				if options.panicCallback != nil {
					defer func() {
						if e := recover(); e != nil {
							options.panicCallback(e)
						}
					}()
				}
				if r != nil {
					r(d)
				}
				if r1 != nil {
					r1(d)
				}
			}
		}
	}
	{
		h1 := lhs.OnPoolNew
		h2 := rhs.OnPoolNew
		ret.OnPoolNew = func(d trace.DriverConnPoolNewStartInfo) func(trace.DriverConnPoolNewDoneInfo) {
			if options.panicCallback != nil {
				defer func() {
					if e := recover(); e != nil {
						options.panicCallback(e)
					}
				}()
			}
			var r, r1 func(trace.DriverConnPoolNewDoneInfo)
			if h1 != nil {
				r = h1(d)
			}
			if h2 != nil {
				r1 = h2(d)
			}
			return func(d trace.DriverConnPoolNewDoneInfo) {
				if options.panicCallback != nil {
					defer func() {
						if e := recover(); e != nil {
							options.panicCallback(e)
						}
					}()
				}
				if r != nil {
					r(d)
				}
				if r1 != nil {
					r1(d)
				}
			}
		}
	}
	{
		h1 := lhs.OnPoolRelease
		h2 := rhs.OnPoolRelease
		ret.OnPoolRelease = func(d trace.DriverConnPoolReleaseStartInfo) func(trace.DriverConnPoolReleaseDoneInfo) {
			if options.panicCallback != nil {
				defer func() {
					if e := recover(); e != nil {
						options.panicCallback(e)
					}
				}()
			}
			var r, r1 func(trace.DriverConnPoolReleaseDoneInfo)
			if h1 != nil {
				r = h1(d)
			}
			if h2 != nil {
				r1 = h2(d)
			}
			return func(d trace.DriverConnPoolReleaseDoneInfo) {
				if options.panicCallback != nil {
					defer func() {
						if e := recover(); e != nil {
							options.panicCallback(e)
						}
					}()
				}
				if r != nil {
					r(d)
				}
				if r1 != nil {
					r1(d)
				}
			}
		}
	}
	{
		h1 := lhs.OnResolve
		h2 := rhs.OnResolve
		ret.OnResolve = func(d trace.DriverResolveStartInfo) func(trace.DriverResolveDoneInfo) {
			if options.panicCallback != nil {
				defer func() {
					if e := recover(); e != nil {
						options.panicCallback(e)
					}
				}()
			}
			var r, r1 func(trace.DriverResolveDoneInfo)
			if h1 != nil {
				r = h1(d)
			}
			if h2 != nil {
				r1 = h2(d)
			}
			return func(d trace.DriverResolveDoneInfo) {
				if options.panicCallback != nil {
					defer func() {
						if e := recover(); e != nil {
							options.panicCallback(e)
						}
					}()
				}
				if r != nil {
					r(d)
				}
				if r1 != nil {
					r1(d)
				}
			}
		}
	}
	{
		h1 := lhs.OnConnStateChange
		h2 := rhs.OnConnStateChange
		ret.OnConnStateChange = func(d trace.DriverConnStateChangeStartInfo) func(trace.DriverConnStateChangeDoneInfo) {
			if options.panicCallback != nil {
				defer func() {
					if e := recover(); e != nil {
						options.panicCallback(e)
					}
				}()
			}
			var r, r1 func(trace.DriverConnStateChangeDoneInfo)
			if h1 != nil {
				r = h1(d)
			}
			if h2 != nil {
				r1 = h2(d)
			}
			return func(d trace.DriverConnStateChangeDoneInfo) {
				if options.panicCallback != nil {
					defer func() {
						if e := recover(); e != nil {
							options.panicCallback(e)
						}
					}()
				}
				if r != nil {
					r(d)
				}
				if r1 != nil {
					r1(d)
				}
			}
		}
	}
	{
		h1 := lhs.OnConnInvoke
		h2 := rhs.OnConnInvoke
		ret.OnConnInvoke = func(d trace.DriverConnInvokeStartInfo) func(trace.DriverConnInvokeDoneInfo) {
			if options.panicCallback != nil {
				defer func() {
					if e := recover(); e != nil {
						options.panicCallback(e)
					}
				}()
			}
			var r, r1 func(trace.DriverConnInvokeDoneInfo)
			if h1 != nil {
				r = h1(d)
			}
			if h2 != nil {
				r1 = h2(d)
			}
			return func(d trace.DriverConnInvokeDoneInfo) {
				if options.panicCallback != nil {
					defer func() {
						if e := recover(); e != nil {
							options.panicCallback(e)
						}
					}()
				}
				if r != nil {
					r(d)
				}
				if r1 != nil {
					r1(d)
				}
			}
		}
	}
	{
		h1 := lhs.OnConnNewStream
		h2 := rhs.OnConnNewStream
		ret.OnConnNewStream = func(d trace.DriverConnNewStreamStartInfo) func(trace.DriverConnNewStreamDoneInfo) {
			if options.panicCallback != nil {
				defer func() {
					if e := recover(); e != nil {
						options.panicCallback(e)
					}
				}()
			}
			var r, r1 func(trace.DriverConnNewStreamDoneInfo)
			if h1 != nil {
				r = h1(d)
			}
			if h2 != nil {
				r1 = h2(d)
			}
			return func(d trace.DriverConnNewStreamDoneInfo) {
				if options.panicCallback != nil {
					defer func() {
						if e := recover(); e != nil {
							options.panicCallback(e)
						}
					}()
				}
				if r != nil {
					r(d)
				}
				if r1 != nil {
					r1(d)
				}
			}
		}
	}
	{
		h1 := lhs.OnConnStreamRecvMsg
		h2 := rhs.OnConnStreamRecvMsg
		ret.OnConnStreamRecvMsg = func(d trace.DriverConnStreamRecvMsgStartInfo) func(trace.DriverConnStreamRecvMsgDoneInfo) {
			if options.panicCallback != nil {
				defer func() {
					if e := recover(); e != nil {
						options.panicCallback(e)
					}
				}()
			}
			var r, r1 func(trace.DriverConnStreamRecvMsgDoneInfo)
			if h1 != nil {
				r = h1(d)
			}
			if h2 != nil {
				r1 = h2(d)
			}
			return func(d trace.DriverConnStreamRecvMsgDoneInfo) {
				if options.panicCallback != nil {
					defer func() {
						if e := recover(); e != nil {
							options.panicCallback(e)
						}
					}()
				}
				if r != nil {
					r(d)
				}
				if r1 != nil {
					r1(d)
				}
			}
		}
	}
	{
		h1 := lhs.OnConnStreamSendMsg
		h2 := rhs.OnConnStreamSendMsg
		ret.OnConnStreamSendMsg = func(d trace.DriverConnStreamSendMsgStartInfo) func(trace.DriverConnStreamSendMsgDoneInfo) {
			if options.panicCallback != nil {
				defer func() {
					if e := recover(); e != nil {
						options.panicCallback(e)
					}
				}()
			}
			var r, r1 func(trace.DriverConnStreamSendMsgDoneInfo)
			if h1 != nil {
				r = h1(d)
			}
			if h2 != nil {
				r1 = h2(d)
			}
			return func(d trace.DriverConnStreamSendMsgDoneInfo) {
				if options.panicCallback != nil {
					defer func() {
						if e := recover(); e != nil {
							options.panicCallback(e)
						}
					}()
				}
				if r != nil {
					r(d)
				}
				if r1 != nil {
					r1(d)
				}
			}
		}
	}
	{
		h1 := lhs.OnConnStreamCloseSend
		h2 := rhs.OnConnStreamCloseSend
		ret.OnConnStreamCloseSend = func(d trace.DriverConnStreamCloseSendStartInfo) func(trace.DriverConnStreamCloseSendDoneInfo) {
			if options.panicCallback != nil {
				defer func() {
					if e := recover(); e != nil {
						options.panicCallback(e)
					}
				}()
			}
			var r, r1 func(trace.DriverConnStreamCloseSendDoneInfo)
			if h1 != nil {
				r = h1(d)
			}
			if h2 != nil {
				r1 = h2(d)
			}
			return func(d trace.DriverConnStreamCloseSendDoneInfo) {
				if options.panicCallback != nil {
					defer func() {
						if e := recover(); e != nil {
							options.panicCallback(e)
						}
					}()
				}
				if r != nil {
					r(d)
				}
				if r1 != nil {
					r1(d)
				}
			}
		}
	}
	{
		h1 := lhs.OnConnStreamFinish
		h2 := rhs.OnConnStreamFinish
		ret.OnConnStreamFinish = func(info trace.DriverConnStreamFinishInfo) {
			if options.panicCallback != nil {
				defer func() {
					if e := recover(); e != nil {
						options.panicCallback(e)
					}
				}()
			}
			if h1 != nil {
				h1(info)
			}
			if h2 != nil {
				h2(info)
			}
		}
	}
	{
		h1 := lhs.OnConnDial
		h2 := rhs.OnConnDial
		ret.OnConnDial = func(d trace.DriverConnDialStartInfo) func(trace.DriverConnDialDoneInfo) {
			if options.panicCallback != nil {
				defer func() {
					if e := recover(); e != nil {
						options.panicCallback(e)
					}
				}()
			}
			var r, r1 func(trace.DriverConnDialDoneInfo)
			if h1 != nil {
				r = h1(d)
			}
			if h2 != nil {
				r1 = h2(d)
			}
			return func(d trace.DriverConnDialDoneInfo) {
				if options.panicCallback != nil {
					defer func() {
						if e := recover(); e != nil {
							options.panicCallback(e)
						}
					}()
				}
				if r != nil {
					r(d)
				}
				if r1 != nil {
					r1(d)
				}
			}
		}
	}
	{
		h1 := lhs.OnConnBan
		h2 := rhs.OnConnBan
		ret.OnConnBan = func(d trace.DriverConnBanStartInfo) func(trace.DriverConnBanDoneInfo) {
			if options.panicCallback != nil {
				defer func() {
					if e := recover(); e != nil {
						options.panicCallback(e)
					}
				}()
			}
			var r, r1 func(trace.DriverConnBanDoneInfo)
			if h1 != nil {
				r = h1(d)
			}
			if h2 != nil {
				r1 = h2(d)
			}
			return func(d trace.DriverConnBanDoneInfo) {
				if options.panicCallback != nil {
					defer func() {
						if e := recover(); e != nil {
							options.panicCallback(e)
						}
					}()
				}
				if r != nil {
					r(d)
				}
				if r1 != nil {
					r1(d)
				}
			}
		}
	}
	{
		h1 := lhs.OnConnAllow
		h2 := rhs.OnConnAllow
		ret.OnConnAllow = func(d trace.DriverConnAllowStartInfo) func(trace.DriverConnAllowDoneInfo) {
			if options.panicCallback != nil {
				defer func() {
					if e := recover(); e != nil {
						options.panicCallback(e)
					}
				}()
			}
			var r, r1 func(trace.DriverConnAllowDoneInfo)
			if h1 != nil {
				r = h1(d)
			}
			if h2 != nil {
				r1 = h2(d)
			}
			return func(d trace.DriverConnAllowDoneInfo) {
				if options.panicCallback != nil {
					defer func() {
						if e := recover(); e != nil {
							options.panicCallback(e)
						}
					}()
				}
				if r != nil {
					r(d)
				}
				if r1 != nil {
					r1(d)
				}
			}
		}
	}
	{
		h1 := lhs.OnConnPark
		h2 := rhs.OnConnPark
		ret.OnConnPark = func(d trace.DriverConnParkStartInfo) func(trace.DriverConnParkDoneInfo) {
			if options.panicCallback != nil {
				defer func() {
					if e := recover(); e != nil {
						options.panicCallback(e)
					}
				}()
			}
			var r, r1 func(trace.DriverConnParkDoneInfo)
			if h1 != nil {
				r = h1(d)
			}
			if h2 != nil {
				r1 = h2(d)
			}
			return func(d trace.DriverConnParkDoneInfo) {
				if options.panicCallback != nil {
					defer func() {
						if e := recover(); e != nil {
							options.panicCallback(e)
						}
					}()
				}
				if r != nil {
					r(d)
				}
				if r1 != nil {
					r1(d)
				}
			}
		}
	}
	{
		h1 := lhs.OnConnClose
		h2 := rhs.OnConnClose
		ret.OnConnClose = func(d trace.DriverConnCloseStartInfo) func(trace.DriverConnCloseDoneInfo) {
			if options.panicCallback != nil {
				defer func() {
					if e := recover(); e != nil {
						options.panicCallback(e)
					}
				}()
			}
			var r, r1 func(trace.DriverConnCloseDoneInfo)
			if h1 != nil {
				r = h1(d)
			}
			if h2 != nil {
				r1 = h2(d)
			}
			return func(d trace.DriverConnCloseDoneInfo) {
				if options.panicCallback != nil {
					defer func() {
						if e := recover(); e != nil {
							options.panicCallback(e)
						}
					}()
				}
				if r != nil {
					r(d)
				}
				if r1 != nil {
					r1(d)
				}
			}
		}
	}
	{
		h1 := lhs.OnRepeaterWakeUp
		h2 := rhs.OnRepeaterWakeUp
		ret.OnRepeaterWakeUp = func(d trace.DriverRepeaterWakeUpStartInfo) func(trace.DriverRepeaterWakeUpDoneInfo) {
			if options.panicCallback != nil {
				defer func() {
					if e := recover(); e != nil {
						options.panicCallback(e)
					}
				}()
			}
			var r, r1 func(trace.DriverRepeaterWakeUpDoneInfo)
			if h1 != nil {
				r = h1(d)
			}
			if h2 != nil {
				r1 = h2(d)
			}
			return func(d trace.DriverRepeaterWakeUpDoneInfo) {
				if options.panicCallback != nil {
					defer func() {
						if e := recover(); e != nil {
							options.panicCallback(e)
						}
					}()
				}
				if r != nil {
					r(d)
				}
				if r1 != nil {
					r1(d)
				}
			}
		}
	}
	{
		h1 := lhs.OnBalancerInit
		h2 := rhs.OnBalancerInit
		ret.OnBalancerInit = func(d trace.DriverBalancerInitStartInfo) func(trace.DriverBalancerInitDoneInfo) {
			if options.panicCallback != nil {
				defer func() {
					if e := recover(); e != nil {
						options.panicCallback(e)
					}
				}()
			}
			var r, r1 func(trace.DriverBalancerInitDoneInfo)
			if h1 != nil {
				r = h1(d)
			}
			if h2 != nil {
				r1 = h2(d)
			}
			return func(d trace.DriverBalancerInitDoneInfo) {
				if options.panicCallback != nil {
					defer func() {
						if e := recover(); e != nil {
							options.panicCallback(e)
						}
					}()
				}
				if r != nil {
					r(d)
				}
				if r1 != nil {
					r1(d)
				}
			}
		}
	}
	{
		h1 := lhs.OnBalancerClose
		h2 := rhs.OnBalancerClose
		ret.OnBalancerClose = func(d trace.DriverBalancerCloseStartInfo) func(trace.DriverBalancerCloseDoneInfo) {
			if options.panicCallback != nil {
				defer func() {
					if e := recover(); e != nil {
						options.panicCallback(e)
					}
				}()
			}
			var r, r1 func(trace.DriverBalancerCloseDoneInfo)
			if h1 != nil {
				r = h1(d)
			}
			if h2 != nil {
				r1 = h2(d)
			}
			return func(d trace.DriverBalancerCloseDoneInfo) {
				if options.panicCallback != nil {
					defer func() {
						if e := recover(); e != nil {
							options.panicCallback(e)
						}
					}()
				}
				if r != nil {
					r(d)
				}
				if r1 != nil {
					r1(d)
				}
			}
		}
	}
	{
		h1 := lhs.OnBalancerChooseEndpoint
		h2 := rhs.OnBalancerChooseEndpoint
		ret.OnBalancerChooseEndpoint = func(d trace.DriverBalancerChooseEndpointStartInfo) func(trace.DriverBalancerChooseEndpointDoneInfo) {
			if options.panicCallback != nil {
				defer func() {
					if e := recover(); e != nil {
						options.panicCallback(e)
					}
				}()
			}
			var r, r1 func(trace.DriverBalancerChooseEndpointDoneInfo)
			if h1 != nil {
				r = h1(d)
			}
			if h2 != nil {
				r1 = h2(d)
			}
			return func(d trace.DriverBalancerChooseEndpointDoneInfo) {
				if options.panicCallback != nil {
					defer func() {
						if e := recover(); e != nil {
							options.panicCallback(e)
						}
					}()
				}
				if r != nil {
					r(d)
				}
				if r1 != nil {
					r1(d)
				}
			}
		}
	}
	{
		h1 := lhs.OnBalancerClusterDiscoveryAttempt
		h2 := rhs.OnBalancerClusterDiscoveryAttempt
		ret.OnBalancerClusterDiscoveryAttempt = func(d trace.DriverBalancerClusterDiscoveryAttemptStartInfo) func(trace.DriverBalancerClusterDiscoveryAttemptDoneInfo) {
			if options.panicCallback != nil {
				defer func() {
					if e := recover(); e != nil {
						options.panicCallback(e)
					}
				}()
			}
			var r, r1 func(trace.DriverBalancerClusterDiscoveryAttemptDoneInfo)
			if h1 != nil {
				r = h1(d)
			}
			if h2 != nil {
				r1 = h2(d)
			}
			return func(d trace.DriverBalancerClusterDiscoveryAttemptDoneInfo) {
				if options.panicCallback != nil {
					defer func() {
						if e := recover(); e != nil {
							options.panicCallback(e)
						}
					}()
				}
				if r != nil {
					r(d)
				}
				if r1 != nil {
					r1(d)
				}
			}
		}
	}
	{
		h1 := lhs.OnBalancerUpdate
		h2 := rhs.OnBalancerUpdate
		ret.OnBalancerUpdate = func(d trace.DriverBalancerUpdateStartInfo) func(trace.DriverBalancerUpdateDoneInfo) {
			if options.panicCallback != nil {
				defer func() {
					if e := recover(); e != nil {
						options.panicCallback(e)
					}
				}()
			}
			var r, r1 func(trace.DriverBalancerUpdateDoneInfo)
			if h1 != nil {
				r = h1(d)
			}
			if h2 != nil {
				r1 = h2(d)
			}
			return func(d trace.DriverBalancerUpdateDoneInfo) {
				if options.panicCallback != nil {
					defer func() {
						if e := recover(); e != nil {
							options.panicCallback(e)
						}
					}()
				}
				if r != nil {
					r(d)
				}
				if r1 != nil {
					r1(d)
				}
			}
		}
	}
	{
		h1 := lhs.OnGetCredentials
		h2 := rhs.OnGetCredentials
		ret.OnGetCredentials = func(d trace.DriverGetCredentialsStartInfo) func(trace.DriverGetCredentialsDoneInfo) {
			if options.panicCallback != nil {
				defer func() {
					if e := recover(); e != nil {
						options.panicCallback(e)
					}
				}()
			}
			var r, r1 func(trace.DriverGetCredentialsDoneInfo)
			if h1 != nil {
				r = h1(d)
			}
			if h2 != nil {
				r1 = h2(d)
			}
			return func(d trace.DriverGetCredentialsDoneInfo) {
				if options.panicCallback != nil {
					defer func() {
						if e := recover(); e != nil {
							options.panicCallback(e)
						}
					}()
				}
				if r != nil {
					r(d)
				}
				if r1 != nil {
					r1(d)
				}
			}
		}
	}
	return &ret
}
func onInit(t *trace.Driver, d trace.DriverInitStartInfo) func(trace.DriverInitDoneInfo) {
	fn := t.OnInit
	if fn == nil {
		return func(trace.DriverInitDoneInfo) {
			return
		}
	}
	res := fn(d)
	if res == nil {
		return func(trace.DriverInitDoneInfo) {
			return
		}
	}
	return res
}
func onWith(t *trace.Driver, d trace.DriverWithStartInfo) func(trace.DriverWithDoneInfo) {
	fn := t.OnWith
	if fn == nil {
		return func(trace.DriverWithDoneInfo) {
			return
		}
	}
	res := fn(d)
	if res == nil {
		return func(trace.DriverWithDoneInfo) {
			return
		}
	}
	return res
}
func onClose(t *trace.Driver, d trace.DriverCloseStartInfo) func(trace.DriverCloseDoneInfo) {
	fn := t.OnClose
	if fn == nil {
		return func(trace.DriverCloseDoneInfo) {
			return
		}
	}
	res := fn(d)
	if res == nil {
		return func(trace.DriverCloseDoneInfo) {
			return
		}
	}
	return res
}
func onPoolNew(t *trace.Driver, d trace.DriverConnPoolNewStartInfo) func(trace.DriverConnPoolNewDoneInfo) {
	fn := t.OnPoolNew
	if fn == nil {
		return func(trace.DriverConnPoolNewDoneInfo) {
			return
		}
	}
	res := fn(d)
	if res == nil {
		return func(trace.DriverConnPoolNewDoneInfo) {
			return
		}
	}
	return res
}
func onPoolRelease(t *trace.Driver, d trace.DriverConnPoolReleaseStartInfo) func(trace.DriverConnPoolReleaseDoneInfo) {
	fn := t.OnPoolRelease
	if fn == nil {
		return func(trace.DriverConnPoolReleaseDoneInfo) {
			return
		}
	}
	res := fn(d)
	if res == nil {
		return func(trace.DriverConnPoolReleaseDoneInfo) {
			return
		}
	}
	return res
}
func onResolve(t *trace.Driver, d trace.DriverResolveStartInfo) func(trace.DriverResolveDoneInfo) {
	fn := t.OnResolve
	if fn == nil {
		return func(trace.DriverResolveDoneInfo) {
			return
		}
	}
	res := fn(d)
	if res == nil {
		return func(trace.DriverResolveDoneInfo) {
			return
		}
	}
	return res
}
func onConnStateChange(t *trace.Driver, d trace.DriverConnStateChangeStartInfo) func(trace.DriverConnStateChangeDoneInfo) {
	fn := t.OnConnStateChange
	if fn == nil {
		return func(trace.DriverConnStateChangeDoneInfo) {
			return
		}
	}
	res := fn(d)
	if res == nil {
		return func(trace.DriverConnStateChangeDoneInfo) {
			return
		}
	}
	return res
}
func onConnInvoke(t *trace.Driver, d trace.DriverConnInvokeStartInfo) func(trace.DriverConnInvokeDoneInfo) {
	fn := t.OnConnInvoke
	if fn == nil {
		return func(trace.DriverConnInvokeDoneInfo) {
			return
		}
	}
	res := fn(d)
	if res == nil {
		return func(trace.DriverConnInvokeDoneInfo) {
			return
		}
	}
	return res
}
func onConnNewStream(t *trace.Driver, d trace.DriverConnNewStreamStartInfo) func(trace.DriverConnNewStreamDoneInfo) {
	fn := t.OnConnNewStream
	if fn == nil {
		return func(trace.DriverConnNewStreamDoneInfo) {
			return
		}
	}
	res := fn(d)
	if res == nil {
		return func(trace.DriverConnNewStreamDoneInfo) {
			return
		}
	}
	return res
}
func onConnStreamRecvMsg(t *trace.Driver, d trace.DriverConnStreamRecvMsgStartInfo) func(trace.DriverConnStreamRecvMsgDoneInfo) {
	fn := t.OnConnStreamRecvMsg
	if fn == nil {
		return func(trace.DriverConnStreamRecvMsgDoneInfo) {
			return
		}
	}
	res := fn(d)
	if res == nil {
		return func(trace.DriverConnStreamRecvMsgDoneInfo) {
			return
		}
	}
	return res
}
func onConnStreamSendMsg(t *trace.Driver, d trace.DriverConnStreamSendMsgStartInfo) func(trace.DriverConnStreamSendMsgDoneInfo) {
	fn := t.OnConnStreamSendMsg
	if fn == nil {
		return func(trace.DriverConnStreamSendMsgDoneInfo) {
			return
		}
	}
	res := fn(d)
	if res == nil {
		return func(trace.DriverConnStreamSendMsgDoneInfo) {
			return
		}
	}
	return res
}
func onConnStreamCloseSend(t *trace.Driver, d trace.DriverConnStreamCloseSendStartInfo) func(trace.DriverConnStreamCloseSendDoneInfo) {
	fn := t.OnConnStreamCloseSend
	if fn == nil {
		return func(trace.DriverConnStreamCloseSendDoneInfo) {
			return
		}
	}
	res := fn(d)
	if res == nil {
		return func(trace.DriverConnStreamCloseSendDoneInfo) {
			return
		}
	}
	return res
}
func onConnStreamFinish(t *trace.Driver, info trace.DriverConnStreamFinishInfo) {
	fn := t.OnConnStreamFinish
	if fn == nil {
		return
	}
	fn(info)
}
func onConnDial(t *trace.Driver, d trace.DriverConnDialStartInfo) func(trace.DriverConnDialDoneInfo) {
	fn := t.OnConnDial
	if fn == nil {
		return func(trace.DriverConnDialDoneInfo) {
			return
		}
	}
	res := fn(d)
	if res == nil {
		return func(trace.DriverConnDialDoneInfo) {
			return
		}
	}
	return res
}
func onConnBan(t *trace.Driver, d trace.DriverConnBanStartInfo) func(trace.DriverConnBanDoneInfo) {
	fn := t.OnConnBan
	if fn == nil {
		return func(trace.DriverConnBanDoneInfo) {
			return
		}
	}
	res := fn(d)
	if res == nil {
		return func(trace.DriverConnBanDoneInfo) {
			return
		}
	}
	return res
}
func onConnAllow(t *trace.Driver, d trace.DriverConnAllowStartInfo) func(trace.DriverConnAllowDoneInfo) {
	fn := t.OnConnAllow
	if fn == nil {
		return func(trace.DriverConnAllowDoneInfo) {
			return
		}
	}
	res := fn(d)
	if res == nil {
		return func(trace.DriverConnAllowDoneInfo) {
			return
		}
	}
	return res
}
func onConnPark(t *trace.Driver, d trace.DriverConnParkStartInfo) func(trace.DriverConnParkDoneInfo) {
	fn := t.OnConnPark
	if fn == nil {
		return func(trace.DriverConnParkDoneInfo) {
			return
		}
	}
	res := fn(d)
	if res == nil {
		return func(trace.DriverConnParkDoneInfo) {
			return
		}
	}
	return res
}
func onConnClose(t *trace.Driver, d trace.DriverConnCloseStartInfo) func(trace.DriverConnCloseDoneInfo) {
	fn := t.OnConnClose
	if fn == nil {
		return func(trace.DriverConnCloseDoneInfo) {
			return
		}
	}
	res := fn(d)
	if res == nil {
		return func(trace.DriverConnCloseDoneInfo) {
			return
		}
	}
	return res
}
func onRepeaterWakeUp(t *trace.Driver, d trace.DriverRepeaterWakeUpStartInfo) func(trace.DriverRepeaterWakeUpDoneInfo) {
	fn := t.OnRepeaterWakeUp
	if fn == nil {
		return func(trace.DriverRepeaterWakeUpDoneInfo) {
			return
		}
	}
	res := fn(d)
	if res == nil {
		return func(trace.DriverRepeaterWakeUpDoneInfo) {
			return
		}
	}
	return res
}
func onBalancerInit(t *trace.Driver, d trace.DriverBalancerInitStartInfo) func(trace.DriverBalancerInitDoneInfo) {
	fn := t.OnBalancerInit
	if fn == nil {
		return func(trace.DriverBalancerInitDoneInfo) {
			return
		}
	}
	res := fn(d)
	if res == nil {
		return func(trace.DriverBalancerInitDoneInfo) {
			return
		}
	}
	return res
}
func onBalancerClose(t *trace.Driver, d trace.DriverBalancerCloseStartInfo) func(trace.DriverBalancerCloseDoneInfo) {
	fn := t.OnBalancerClose
	if fn == nil {
		return func(trace.DriverBalancerCloseDoneInfo) {
			return
		}
	}
	res := fn(d)
	if res == nil {
		return func(trace.DriverBalancerCloseDoneInfo) {
			return
		}
	}
	return res
}
func onBalancerChooseEndpoint(t *trace.Driver, d trace.DriverBalancerChooseEndpointStartInfo) func(trace.DriverBalancerChooseEndpointDoneInfo) {
	fn := t.OnBalancerChooseEndpoint
	if fn == nil {
		return func(trace.DriverBalancerChooseEndpointDoneInfo) {
			return
		}
	}
	res := fn(d)
	if res == nil {
		return func(trace.DriverBalancerChooseEndpointDoneInfo) {
			return
		}
	}
	return res
}
func onBalancerClusterDiscoveryAttempt(t *trace.Driver, d trace.DriverBalancerClusterDiscoveryAttemptStartInfo) func(trace.DriverBalancerClusterDiscoveryAttemptDoneInfo) {
	fn := t.OnBalancerClusterDiscoveryAttempt
	if fn == nil {
		return func(trace.DriverBalancerClusterDiscoveryAttemptDoneInfo) {
			return
		}
	}
	res := fn(d)
	if res == nil {
		return func(trace.DriverBalancerClusterDiscoveryAttemptDoneInfo) {
			return
		}
	}
	return res
}
func onBalancerUpdate(t *trace.Driver, d trace.DriverBalancerUpdateStartInfo) func(trace.DriverBalancerUpdateDoneInfo) {
	fn := t.OnBalancerUpdate
	if fn == nil {
		return func(trace.DriverBalancerUpdateDoneInfo) {
			return
		}
	}
	res := fn(d)
	if res == nil {
		return func(trace.DriverBalancerUpdateDoneInfo) {
			return
		}
	}
	return res
}
func onGetCredentials(t *trace.Driver, d trace.DriverGetCredentialsStartInfo) func(trace.DriverGetCredentialsDoneInfo) {
	fn := t.OnGetCredentials
	if fn == nil {
		return func(trace.DriverGetCredentialsDoneInfo) {
			return
		}
	}
	res := fn(d)
	if res == nil {
		return func(trace.DriverGetCredentialsDoneInfo) {
			return
		}
	}
	return res
}
// Internals: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#internals
func DriverOnInit(t *trace.Driver, c *context.Context, c1 trace.Call, endpoint string, database string, secure bool) func(error) {
	var p trace.DriverInitStartInfo
	p.Context = c
	p.Call = c1
	p.Endpoint = endpoint
	p.Database = database
	p.Secure = secure
	res := onInit(t, p)
	return func(e error) {
		var p trace.DriverInitDoneInfo
		p.Error = e
		res(p)
	}
}
// Internals: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#internals
func DriverOnWith(t *trace.Driver, c *context.Context, c1 trace.Call, endpoint string, database string, secure bool) func(error) {
	var p trace.DriverWithStartInfo
	p.Context = c
	p.Call = c1
	p.Endpoint = endpoint
	p.Database = database
	p.Secure = secure
	res := onWith(t, p)
	return func(e error) {
		var p trace.DriverWithDoneInfo
		p.Error = e
		res(p)
	}
}
// Internals: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#internals
func DriverOnClose(t *trace.Driver, c *context.Context, c1 trace.Call) func(error) {
	var p trace.DriverCloseStartInfo
	p.Context = c
	p.Call = c1
	res := onClose(t, p)
	return func(e error) {
		var p trace.DriverCloseDoneInfo
		p.Error = e
		res(p)
	}
}
// Internals: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#internals
func DriverOnPoolNew(t *trace.Driver, c *context.Context, c1 trace.Call) func() {
	var p trace.DriverConnPoolNewStartInfo
	p.Context = c
	p.Call = c1
	res := onPoolNew(t, p)
	return func() {
		var p trace.DriverConnPoolNewDoneInfo
		res(p)
	}
}
// Internals: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#internals
func DriverOnPoolRelease(t *trace.Driver, c *context.Context, c1 trace.Call) func(error) {
	var p trace.DriverConnPoolReleaseStartInfo
	p.Context = c
	p.Call = c1
	res := onPoolRelease(t, p)
	return func(e error) {
		var p trace.DriverConnPoolReleaseDoneInfo
		p.Error = e
		res(p)
	}
}
// Internals: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#internals
func DriverOnResolve(t *trace.Driver, c trace.Call, target string, resolved []string) func(error) {
	var p trace.DriverResolveStartInfo
	p.Call = c
	p.Target = target
	p.Resolved = resolved
	res := onResolve(t, p)
	return func(e error) {
		var p trace.DriverResolveDoneInfo
		p.Error = e
		res(p)
	}
}
// Internals: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#internals
func DriverOnConnStateChange(t *trace.Driver, c *context.Context, c1 trace.Call, endpoint trace.EndpointInfo, state trace.ConnState) func(state trace.ConnState) {
	var p trace.DriverConnStateChangeStartInfo
	p.Context = c
	p.Call = c1
	p.Endpoint = endpoint
	p.State = state
	res := onConnStateChange(t, p)
	return func(state trace.ConnState) {
		var p trace.DriverConnStateChangeDoneInfo
		p.State = state
		res(p)
	}
}
// Internals: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#internals
func DriverOnConnInvoke(t *trace.Driver, c *context.Context, c1 trace.Call, endpoint trace.EndpointInfo, m trace.Method) func(_ error, issues []trace.Issue, opID string, state trace.ConnState, metadata map[string][]string) {
	var p trace.DriverConnInvokeStartInfo
	p.Context = c
	p.Call = c1
	p.Endpoint = endpoint
	p.Method = m
	res := onConnInvoke(t, p)
	return func(e error, issues []trace.Issue, opID string, state trace.ConnState, metadata map[string][]string) {
		var p trace.DriverConnInvokeDoneInfo
		p.Error = e
		p.Issues = issues
		p.OpID = opID
		p.State = state
		p.Metadata = metadata
		res(p)
	}
}
// Internals: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#internals
func DriverOnConnNewStream(t *trace.Driver, c *context.Context, c1 trace.Call, endpoint trace.EndpointInfo, m trace.Method) func(_ error, state trace.ConnState) {
	var p trace.DriverConnNewStreamStartInfo
	p.Context = c
	p.Call = c1
	p.Endpoint = endpoint
	p.Method = m
	res := onConnNewStream(t, p)
	return func(e error, state trace.ConnState) {
		var p trace.DriverConnNewStreamDoneInfo
		p.Error = e
		p.State = state
		res(p)
	}
}
// Internals: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#internals
func DriverOnConnStreamRecvMsg(t *trace.Driver, c *context.Context, c1 trace.Call) func(error) {
	var p trace.DriverConnStreamRecvMsgStartInfo
	p.Context = c
	p.Call = c1
	res := onConnStreamRecvMsg(t, p)
	return func(e error) {
		var p trace.DriverConnStreamRecvMsgDoneInfo
		p.Error = e
		res(p)
	}
}
// Internals: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#internals
func DriverOnConnStreamSendMsg(t *trace.Driver, c *context.Context, c1 trace.Call) func(error) {
	var p trace.DriverConnStreamSendMsgStartInfo
	p.Context = c
	p.Call = c1
	res := onConnStreamSendMsg(t, p)
	return func(e error) {
		var p trace.DriverConnStreamSendMsgDoneInfo
		p.Error = e
		res(p)
	}
}
// Internals: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#internals
func DriverOnConnStreamCloseSend(t *trace.Driver, c *context.Context, c1 trace.Call) func(error) {
	var p trace.DriverConnStreamCloseSendStartInfo
	p.Context = c
	p.Call = c1
	res := onConnStreamCloseSend(t, p)
	return func(e error) {
		var p trace.DriverConnStreamCloseSendDoneInfo
		p.Error = e
		res(p)
	}
}
// Internals: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#internals
func DriverOnConnStreamFinish(t *trace.Driver, c context.Context, c1 trace.Call, e error) {
	var p trace.DriverConnStreamFinishInfo
	p.Context = c
	p.Call = c1
	p.Error = e
	onConnStreamFinish(t, p)
}
// Internals: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#internals
func DriverOnConnDial(t *trace.Driver, c *context.Context, c1 trace.Call, endpoint trace.EndpointInfo) func(error) {
	var p trace.DriverConnDialStartInfo
	p.Context = c
	p.Call = c1
	p.Endpoint = endpoint
	res := onConnDial(t, p)
	return func(e error) {
		var p trace.DriverConnDialDoneInfo
		p.Error = e
		res(p)
	}
}
// Internals: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#internals
func DriverOnConnBan(t *trace.Driver, c *context.Context, c1 trace.Call, endpoint trace.EndpointInfo, state trace.ConnState, cause error) func(state trace.ConnState) {
	var p trace.DriverConnBanStartInfo
	p.Context = c
	p.Call = c1
	p.Endpoint = endpoint
	p.State = state
	p.Cause = cause
	res := onConnBan(t, p)
	return func(state trace.ConnState) {
		var p trace.DriverConnBanDoneInfo
		p.State = state
		res(p)
	}
}
// Internals: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#internals
func DriverOnConnAllow(t *trace.Driver, c *context.Context, c1 trace.Call, endpoint trace.EndpointInfo, state trace.ConnState) func(state trace.ConnState) {
	var p trace.DriverConnAllowStartInfo
	p.Context = c
	p.Call = c1
	p.Endpoint = endpoint
	p.State = state
	res := onConnAllow(t, p)
	return func(state trace.ConnState) {
		var p trace.DriverConnAllowDoneInfo
		p.State = state
		res(p)
	}
}
// Internals: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#internals
func DriverOnConnPark(t *trace.Driver, c *context.Context, c1 trace.Call, endpoint trace.EndpointInfo) func(error) {
	var p trace.DriverConnParkStartInfo
	p.Context = c
	p.Call = c1
	p.Endpoint = endpoint
	res := onConnPark(t, p)
	return func(e error) {
		var p trace.DriverConnParkDoneInfo
		p.Error = e
		res(p)
	}
}
// Internals: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#internals
func DriverOnConnClose(t *trace.Driver, c *context.Context, c1 trace.Call, endpoint trace.EndpointInfo) func(error) {
	var p trace.DriverConnCloseStartInfo
	p.Context = c
	p.Call = c1
	p.Endpoint = endpoint
	res := onConnClose(t, p)
	return func(e error) {
		var p trace.DriverConnCloseDoneInfo
		p.Error = e
		res(p)
	}
}
// Internals: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#internals
func DriverOnRepeaterWakeUp(t *trace.Driver, c *context.Context, c1 trace.Call, name string, event string) func(error) {
	var p trace.DriverRepeaterWakeUpStartInfo
	p.Context = c
	p.Call = c1
	p.Name = name
	p.Event = event
	res := onRepeaterWakeUp(t, p)
	return func(e error) {
		var p trace.DriverRepeaterWakeUpDoneInfo
		p.Error = e
		res(p)
	}
}
// Internals: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#internals
func DriverOnBalancerInit(t *trace.Driver, c *context.Context, c1 trace.Call, name string) func(error) {
	var p trace.DriverBalancerInitStartInfo
	p.Context = c
	p.Call = c1
	p.Name = name
	res := onBalancerInit(t, p)
	return func(e error) {
		var p trace.DriverBalancerInitDoneInfo
		p.Error = e
		res(p)
	}
}
// Internals: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#internals
func DriverOnBalancerClose(t *trace.Driver, c *context.Context, c1 trace.Call) func(error) {
	var p trace.DriverBalancerCloseStartInfo
	p.Context = c
	p.Call = c1
	res := onBalancerClose(t, p)
	return func(e error) {
		var p trace.DriverBalancerCloseDoneInfo
		p.Error = e
		res(p)
	}
}
// Internals: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#internals
func DriverOnBalancerChooseEndpoint(t *trace.Driver, c *context.Context, c1 trace.Call) func(endpoint trace.EndpointInfo, _ error) {
	var p trace.DriverBalancerChooseEndpointStartInfo
	p.Context = c
	p.Call = c1
	res := onBalancerChooseEndpoint(t, p)
	return func(endpoint trace.EndpointInfo, e error) {
		var p trace.DriverBalancerChooseEndpointDoneInfo
		p.Endpoint = endpoint
		p.Error = e
		res(p)
	}
}
// Internals: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#internals
func DriverOnBalancerClusterDiscoveryAttempt(t *trace.Driver, c *context.Context, c1 trace.Call, address string, database string) func(error) {
	var p trace.DriverBalancerClusterDiscoveryAttemptStartInfo
	p.Context = c
	p.Call = c1
	p.Address = address
	p.Database = database
	res := onBalancerClusterDiscoveryAttempt(t, p)
	return func(e error) {
		var p trace.DriverBalancerClusterDiscoveryAttemptDoneInfo
		p.Error = e
		res(p)
	}
}
// Internals: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#internals
func DriverOnBalancerUpdate(t *trace.Driver, c *context.Context, c1 trace.Call, needLocalDC bool, database string) func(endpoints []trace.EndpointInfo, added []trace.EndpointInfo, dropped []trace.EndpointInfo, localDC string) {
	var p trace.DriverBalancerUpdateStartInfo
	p.Context = c
	p.Call = c1
	p.NeedLocalDC = needLocalDC
	p.Database = database
	res := onBalancerUpdate(t, p)
	return func(endpoints []trace.EndpointInfo, added []trace.EndpointInfo, dropped []trace.EndpointInfo, localDC string) {
		var p trace.DriverBalancerUpdateDoneInfo
		p.Endpoints = endpoints
		p.Added = added
		p.Dropped = dropped
		p.LocalDC = localDC
		res(p)
	}
}
// Internals: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#internals
func DriverOnGetCredentials(t *trace.Driver, c *context.Context, c1 trace.Call) func(token string, _ error) {
	var p trace.DriverGetCredentialsStartInfo
	p.Context = c
	p.Call = c1
	res := onGetCredentials(t, p)
	return func(token string, e error) {
		var p trace.DriverGetCredentialsDoneInfo
		p.Token = token
		p.Error = e
		res(p)
	}
}
