本文整理汇总了Golang中github.com/cockroachdb/cockroach/util/tracing.AnnotateTrace函数的典型用法代码示例。如果您正苦于以下问题:Golang AnnotateTrace函数的具体用法?Golang AnnotateTrace怎么用?Golang AnnotateTrace使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了AnnotateTrace函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: sendRPC
// sendRPC sends one or more RPCs to replicas from the supplied roachpb.Replica
// slice. Returns an RPC error if the request could not be sent. Note
// that the reply may contain a higher level error and must be checked in
// addition to the RPC error.
// The replicas are assume to have been ordered by preference, closer ones (if
// any) at the front.
func (ds *DistSender) sendRPC(
ctx context.Context,
rangeID roachpb.RangeID,
replicas ReplicaSlice,
ba roachpb.BatchRequest,
) (*roachpb.BatchResponse, error) {
if len(replicas) == 0 {
return nil, noNodeAddrsAvailError{}
}
// TODO(pmattis): This needs to be tested. If it isn't set we'll
// still route the request appropriately by key, but won't receive
// RangeNotFoundErrors.
ba.RangeID = rangeID
// Set RPC opts with stipulation that one of N RPCs must succeed.
rpcOpts := SendOptions{
SendNextTimeout: ds.sendNextTimeout,
Timeout: base.NetworkTimeout,
Context: ctx,
transportFactory: ds.transportFactory,
}
tracing.AnnotateTrace()
defer tracing.AnnotateTrace()
reply, err := ds.sendToReplicas(rpcOpts, rangeID, replicas, ba, ds.rpcContext)
if err != nil {
return nil, err
}
return reply, nil
}
示例2: sendRPC
// sendRPC sends one or more RPCs to replicas from the supplied roachpb.Replica
// slice. First, replicas which have gossiped addresses are corralled (and
// rearranged depending on proximity and whether the request needs to go to a
// leader) and then sent via Send, with requirement that one RPC to a server
// must succeed. Returns an RPC error if the request could not be sent. Note
// that the reply may contain a higher level error and must be checked in
// addition to the RPC error.
func (ds *DistSender) sendRPC(trace opentracing.Span, rangeID roachpb.RangeID, replicas ReplicaSlice,
order orderingPolicy, ba roachpb.BatchRequest) (*roachpb.BatchResponse, *roachpb.Error) {
if len(replicas) == 0 {
return nil, roachpb.NewError(noNodeAddrsAvailError{})
}
// TODO(pmattis): This needs to be tested. If it isn't set we'll
// still route the request appropriately by key, but won't receive
// RangeNotFoundErrors.
ba.RangeID = rangeID
// Set RPC opts with stipulation that one of N RPCs must succeed.
rpcOpts := SendOptions{
Ordering: order,
SendNextTimeout: defaultSendNextTimeout,
Timeout: rpc.DefaultRPCTimeout,
Trace: trace,
}
tracing.AnnotateTrace()
defer tracing.AnnotateTrace()
reply, err := ds.rpcSend(rpcOpts, replicas, ba, ds.rpcContext)
if err != nil {
return nil, roachpb.NewError(err)
}
return reply.(*roachpb.BatchResponse), nil
}
示例3: Run
// Run implements Runner.Run(). See comments there.
func (txn *Txn) Run(b *Batch) error {
tracing.AnnotateTrace()
defer tracing.AnnotateTrace()
if err := b.prepare(); err != nil {
return err
}
return sendAndFill(txn.send, b)
}
示例4: RunWithResponse
// RunWithResponse is a version of Run that returns the BatchResponse.
func (txn *Txn) RunWithResponse(b *Batch) (*roachpb.BatchResponse, *roachpb.Error) {
tracing.AnnotateTrace()
defer tracing.AnnotateTrace()
if pErr := b.prepare(); pErr != nil {
return nil, pErr
}
return sendAndFill(txn.send, b)
}
示例5: executeStatements
func (c *v3Conn) executeStatements(stmts string, params []parser.Datum, formatCodes []formatCode, sendDescription bool, limit int32) error {
tracing.AnnotateTrace()
results := c.executor.ExecuteStatements(c.session, stmts, params)
tracing.AnnotateTrace()
if results.Empty {
// Skip executor and just send EmptyQueryResponse.
c.writeBuf.initMsg(serverMsgEmptyQuery)
return c.writeBuf.finishMsg(c.wr)
}
return c.sendResponse(results.ResultList, formatCodes, sendDescription, limit)
}
示例6: executeStatements
func (c *v3Conn) executeStatements(stmts string, params []parser.Datum, formatCodes []formatCode, sendDescription bool) error {
tracing.AnnotateTrace()
c.session.Database = c.opts.database
// TODO(dt): this is a clumsy check better left to the actual parser. #3852
if len(strings.TrimSpace(stmts)) == 0 {
// Skip executor and just send EmptyQueryResponse.
c.writeBuf.initMsg(serverMsgEmptyQuery)
return c.writeBuf.finishMsg(c.wr)
}
resp, _, err := c.executor.ExecuteStatements(c.opts.user, c.session, stmts, params)
if err != nil {
return c.sendError(err.Error())
}
c.session.Reset()
if err := c.session.Unmarshal(resp.Session); err != nil {
return err
}
c.opts.database = c.session.Database
return c.sendResponse(resp, formatCodes, sendDescription)
}
示例7: Next
func (n *scanNode) Next() bool {
tracing.AnnotateTrace()
if n.pErr != nil {
return false
}
if n.kvs == nil {
if !n.initScan() {
return false
}
}
// All of the columns for a particular row will be grouped together. We loop
// over the key/value pairs and decode the key to extract the columns encoded
// within the key and the column ID. We use the column ID to lookup the
// column and decode the value. All of these values go into a map keyed by
// column name. When the index key changes we output a row containing the
// current values.
for {
if n.maybeOutputRow() {
return n.pErr == nil
}
if n.kvIndex == len(n.kvs) {
return false
}
if !n.processKV(n.kvs[n.kvIndex]) {
return false
}
n.kvIndex++
}
}
示例8: send
// send runs the specified calls synchronously in a single batch and returns
// any errors. Returns a nil response for empty input (no requests).
func (db *DB) send(maxScanResults int64, reqs ...roachpb.Request) (
*roachpb.BatchResponse, *roachpb.Error) {
if len(reqs) == 0 {
return nil, nil
}
ba := roachpb.BatchRequest{}
ba.Add(reqs...)
ba.MaxScanResults = maxScanResults
if db.userPriority != 1 {
ba.UserPriority = db.userPriority
}
tracing.AnnotateTrace()
br, pErr := db.sender.Send(context.TODO(), ba)
if pErr != nil {
if log.V(1) {
log.Infof("failed batch: %s", pErr)
}
return nil, pErr
}
return br, nil
}
示例9: Next
func (n *scanNode) Next() bool {
tracing.AnnotateTrace()
if n.err != nil {
return false
}
if !n.scanInitialized && !n.initScan() {
// Hit error during initScan
return false
}
if n.explain == explainDebug {
return n.debugNext()
}
// We fetch one row at a time until we find one that passes the filter.
for {
n.row, n.err = n.fetcher.NextRow()
if n.err != nil || n.row == nil {
return false
}
passesFilter, err := runFilter(n.filter, n.planner.evalCtx)
if err != nil {
n.err = err
return false
}
if passesFilter {
return true
}
}
}
示例10: send
// send runs the specified calls synchronously in a single batch and returns
// any errors. Returns a nil response for empty input (no requests).
func (db *DB) send(maxScanResults int64, readConsistency roachpb.ReadConsistencyType,
reqs ...roachpb.Request) (*roachpb.BatchResponse, *roachpb.Error) {
if len(reqs) == 0 {
return nil, nil
}
if readConsistency == roachpb.INCONSISTENT {
for _, req := range reqs {
if req.Method() != roachpb.Get && req.Method() != roachpb.Scan &&
req.Method() != roachpb.ReverseScan {
return nil, roachpb.NewErrorf("method %s not allowed with INCONSISTENT batch", req.Method)
}
}
}
ba := roachpb.BatchRequest{}
ba.Add(reqs...)
ba.MaxScanResults = maxScanResults
if db.userPriority != 1 {
ba.UserPriority = db.userPriority
}
ba.ReadConsistency = readConsistency
tracing.AnnotateTrace()
br, pErr := db.sender.Send(context.TODO(), ba)
if pErr != nil {
if log.V(1) {
log.Infof("failed batch: %s", pErr)
}
return nil, pErr
}
return br, nil
}
示例11: send
// send runs the specified calls synchronously in a single batch and returns
// any errors. Returns (nil, nil) for an empty batch.
func (db *DB) send(ba roachpb.BatchRequest) (*roachpb.BatchResponse, *roachpb.Error) {
if len(ba.Requests) == 0 {
return nil, nil
}
if ba.ReadConsistency == roachpb.INCONSISTENT {
for _, ru := range ba.Requests {
req := ru.GetInner()
if req.Method() != roachpb.Get && req.Method() != roachpb.Scan &&
req.Method() != roachpb.ReverseScan {
return nil, roachpb.NewErrorf("method %s not allowed with INCONSISTENT batch", req.Method)
}
}
}
if db.ctx.UserPriority != 1 {
ba.UserPriority = db.ctx.UserPriority
}
tracing.AnnotateTrace()
br, pErr := db.sender.Send(context.TODO(), ba)
if pErr != nil {
if log.V(1) {
log.Infof("failed batch: %s", pErr)
}
return nil, pErr
}
return br, nil
}
示例12: Next
func (n *scanNode) Next() (bool, error) {
tracing.AnnotateTrace()
if !n.scanInitialized {
if err := n.initScan(); err != nil {
return false, nil
}
}
if n.explain == explainDebug {
return n.debugNext()
}
// We fetch one row at a time until we find one that passes the filter.
for {
var err error
n.row, err = n.fetcher.NextRow()
if err != nil || n.row == nil {
return false, err
}
passesFilter, err := sqlbase.RunFilter(n.filter, n.p.evalCtx)
if err != nil {
return false, err
}
if passesFilter {
return true, nil
}
}
}
示例13: Next
func (u *updateNode) Next() (bool, error) {
next, err := u.run.rows.Next()
if !next {
if err == nil {
// We're done. Finish the batch.
err = u.tw.finalize()
}
return false, err
}
if u.run.explain == explainDebug {
return true, nil
}
tracing.AnnotateTrace()
oldValues := u.run.rows.Values()
// Our updated value expressions occur immediately after the plain
// columns in the output.
updateValues := oldValues[len(u.tw.ru.fetchCols):]
oldValues = oldValues[:len(u.tw.ru.fetchCols)]
u.checkHelper.loadRow(u.tw.ru.fetchColIDtoRowIndex, oldValues, false)
u.checkHelper.loadRow(u.updateColsIdx, updateValues, true)
if err := u.checkHelper.check(&u.p.evalCtx); err != nil {
return false, err
}
// Ensure that the values honor the specified column widths.
for i := range updateValues {
if err := sqlbase.CheckValueWidth(u.tw.ru.updateCols[i], updateValues[i]); err != nil {
return false, err
}
}
// Update the row values.
for i, col := range u.tw.ru.updateCols {
val := updateValues[i]
if !col.Nullable && val == parser.DNull {
return false, sqlbase.NewNonNullViolationError(col.Name)
}
}
newValues, err := u.tw.row(append(oldValues, updateValues...))
if err != nil {
return false, err
}
resultRow, err := u.rh.cookResultRow(newValues)
if err != nil {
return false, err
}
u.run.resultRow = resultRow
return true, nil
}
示例14: executeStatements
func (c *v3Conn) executeStatements(
ctx context.Context,
stmts string,
pinfo *parser.PlaceholderInfo,
formatCodes []formatCode,
sendDescription bool,
limit int,
) error {
tracing.AnnotateTrace()
results := c.executor.ExecuteStatements(ctx, c.session, stmts, pinfo)
tracing.AnnotateTrace()
if results.Empty {
// Skip executor and just send EmptyQueryResponse.
c.writeBuf.initMsg(serverMsgEmptyQuery)
return c.writeBuf.finishMsg(c.wr)
}
return c.sendResponse(results.ResultList, formatCodes, sendDescription, limit)
}
示例15: Next
func (u *updateNode) Next() bool {
if u.run.done || u.run.err != nil {
return false
}
if !u.run.rows.Next() {
// We're done. Finish the batch.
err := u.tw.finalize()
u.run.err = err
u.run.done = true
return false
}
tracing.AnnotateTrace()
oldValues := u.run.rows.Values()
// Our updated value expressions occur immediately after the plain
// columns in the output.
updateValues := oldValues[len(u.tableDesc.Columns):]
oldValues = oldValues[:len(u.tableDesc.Columns)]
// Ensure that the values honor the specified column widths.
for i := range updateValues {
if err := sqlbase.CheckValueWidth(u.updateCols[i], updateValues[i]); err != nil {
u.run.err = err
return false
}
}
// Update the row values.
for i, col := range u.updateCols {
val := updateValues[i]
if !col.Nullable && val == parser.DNull {
u.run.err = fmt.Errorf("null value in column %q violates not-null constraint", col.Name)
return false
}
}
newValues, err := u.tw.row(append(oldValues, updateValues...))
if err != nil {
u.run.err = err
return false
}
resultRow, err := u.rh.cookResultRow(newValues)
if err != nil {
u.run.err = err
return false
}
u.run.resultRow = resultRow
return true
}