Example #1
0
	"github.com/henryanand/vitess/go/streamlog"
	"github.com/henryanand/vitess/go/sync2"
	"github.com/henryanand/vitess/go/timer"
	"github.com/henryanand/vitess/go/vt/dbconnpool"
)

/* Function naming convention:
UpperCaseFunctions() are thread safe, they can still panic on error
lowerCaseFunctions() are not thread safe
SafeFunctions() return os.Error instead of throwing exceptions
*/

// TxLogger can be used to enable logging of transactions.
// Call TxLogger.ServeLogs in your main program to enable logging.
// The log format can be inferred by looking at TxConnection.Format.
var TxLogger = streamlog.New("TxLog", 10)

var (
	BEGIN    = "begin"
	COMMIT   = "commit"
	ROLLBACK = "rollback"
)

const (
	TX_CLOSE    = "close"
	TX_COMMIT   = "commit"
	TX_ROLLBACK = "rollback"
	TX_KILL     = "kill"
)

const txLogInterval = time.Duration(1 * time.Minute)
Example #2
0
import (
	"encoding/json"
	"fmt"
	"html/template"
	"net/url"
	"strings"
	"time"

	"code.google.com/p/go.net/context"
	log "github.com/golang/glog"
	"github.com/henryanand/vitess/go/sqltypes"
	"github.com/henryanand/vitess/go/streamlog"
	"github.com/henryanand/vitess/go/vt/callinfo"
)

var SqlQueryLogger = streamlog.New("SqlQuery", 50)

const (
	QUERY_SOURCE_ROWCACHE = 1 << iota
	QUERY_SOURCE_CONSOLIDATOR
	QUERY_SOURCE_MYSQL
)

type SQLQueryStats struct {
	Method               string
	PlanType             string
	OriginalSql          string
	BindVariables        map[string]interface{}
	rewrittenSqls        []string
	RowsAffected         int
	NumberOfQueries      int