-
Notifications
You must be signed in to change notification settings - Fork 110
Opentracing #154
Opentracing #154
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,3 +28,5 @@ benchmark/*tbl | |
vendor | ||
Makefile.main | ||
.ci/ | ||
_example/main | ||
_example/*.exe |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package server | ||
|
||
import ( | ||
"io" | ||
|
||
opentracing "github.com/opentracing/opentracing-go" | ||
jaeger "github.com/uber/jaeger-client-go" | ||
jaegercfg "github.com/uber/jaeger-client-go/config" | ||
"github.com/uber/jaeger-lib/metrics" | ||
"gopkg.in/src-d/go-vitess.v0/mysql" | ||
) | ||
|
||
const ( | ||
jaegerDefaultServiceName = "go-mysql-server" | ||
) | ||
|
||
// Config for the mysql server. | ||
type Config struct { | ||
// Protocol for the connection. | ||
Protocol string | ||
// Address of the server. | ||
Address string | ||
// Auth of the server. | ||
Auth mysql.AuthServer | ||
} | ||
|
||
// Tracer creates a new tracer for the current configuration. It also returns | ||
// an io.Closer to close the tracer and an error, if any. | ||
func (c Config) Tracer() (opentracing.Tracer, io.Closer, error) { | ||
cfg, err := jaegercfg.FromEnv() | ||
if err != nil { | ||
return nil, nil, err | ||
} | ||
|
||
if cfg.ServiceName == "" { | ||
cfg.ServiceName = jaegerDefaultServiceName | ||
} | ||
|
||
return cfg.NewTracer( | ||
jaegercfg.Logger(jaeger.StdLogger), | ||
jaegercfg.Metrics(metrics.NullFactory), | ||
) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,9 +56,6 @@ func (c *Count) TransformUp(f sql.TransformExprFunc) (sql.Expression, error) { | |
|
||
// Update implements the Aggregation interface. | ||
func (c *Count) Update(ctx *sql.Context, buffer, row sql.Row) error { | ||
span, ctx := ctx.Span("aggregation.Count_Update") | ||
defer span.Finish() | ||
|
||
var inc bool | ||
if _, ok := c.Child.(*expression.Star); ok { | ||
inc = true | ||
|
@@ -82,14 +79,16 @@ func (c *Count) Update(ctx *sql.Context, buffer, row sql.Row) error { | |
|
||
// Merge implements the Aggregation interface. | ||
func (c *Count) Merge(ctx *sql.Context, buffer, partial sql.Row) error { | ||
span, _ := ctx.Span("aggregation.Count_Merge") | ||
defer span.Finish() | ||
|
||
buffer[0] = buffer[0].(int32) + partial[0].(int32) | ||
return nil | ||
} | ||
|
||
// Eval implements the Aggregation interface. | ||
func (c *Count) Eval(ctx *sql.Context, buffer sql.Row) (interface{}, error) { | ||
return buffer[0], nil | ||
span, ctx := ctx.Span("aggregation.Count_Eval") | ||
count := buffer[0] | ||
span.LogKV("count", count) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why do we need the result of the aggregation in the log? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ...just to be consistent with other operations (max, min, avg, ...) if it's too noisy we can remove it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, perhaps having in the logs the results of these operations is too noisy |
||
span.Finish() | ||
|
||
return count, nil | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is the casting needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
because
mem.NewDatabase
returnssql.Database
interface which does not haveAddTable
function.