Remove opentracing and profiling
This commit is contained in:
parent
d242fddb26
commit
ca6d956a49
4 changed files with 0 additions and 104 deletions
|
@ -20,7 +20,6 @@ import (
|
||||||
"github.com/abcum/surreal/db"
|
"github.com/abcum/surreal/db"
|
||||||
"github.com/abcum/surreal/kvs"
|
"github.com/abcum/surreal/kvs"
|
||||||
"github.com/abcum/surreal/log"
|
"github.com/abcum/surreal/log"
|
||||||
"github.com/abcum/surreal/trc"
|
|
||||||
"github.com/abcum/surreal/web"
|
"github.com/abcum/surreal/web"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -32,11 +31,6 @@ var startCmd = &cobra.Command{
|
||||||
},
|
},
|
||||||
RunE: func(cmd *cobra.Command, args []string) (err error) {
|
RunE: func(cmd *cobra.Command, args []string) (err error) {
|
||||||
|
|
||||||
if err = trc.Setup(opts); err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if err = kvs.Setup(opts); err != nil {
|
if err = kvs.Setup(opts); err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
return
|
return
|
||||||
|
|
|
@ -27,7 +27,6 @@ import (
|
||||||
"github.com/abcum/surreal/kvs"
|
"github.com/abcum/surreal/kvs"
|
||||||
"github.com/abcum/surreal/log"
|
"github.com/abcum/surreal/log"
|
||||||
"github.com/abcum/surreal/sql"
|
"github.com/abcum/surreal/sql"
|
||||||
"github.com/abcum/surreal/trc"
|
|
||||||
"github.com/abcum/surreal/txn"
|
"github.com/abcum/surreal/txn"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -69,13 +68,6 @@ func newExecutor(id, ns, db string) (e *executor) {
|
||||||
|
|
||||||
func (e *executor) execute(ctx context.Context, ast *sql.Query) {
|
func (e *executor) execute(ctx context.Context, ast *sql.Query) {
|
||||||
|
|
||||||
// Create a new trace span so we can analyse
|
|
||||||
// the execution time of this method, and
|
|
||||||
// detect problems with long-running queries.
|
|
||||||
|
|
||||||
ctx, span := trc.Start(ctx, "db::execute")
|
|
||||||
defer span.End()
|
|
||||||
|
|
||||||
// Ensure that the executor is added back into
|
// Ensure that the executor is added back into
|
||||||
// the executor pool when the executor has
|
// the executor pool when the executor has
|
||||||
// finished processing the request.
|
// finished processing the request.
|
||||||
|
@ -109,8 +101,6 @@ func (e *executor) execute(ctx context.Context, ast *sql.Query) {
|
||||||
if log.IsError() {
|
if log.IsError() {
|
||||||
log.WithPrefix(logKeyDB).WithFields(map[string]interface{}{
|
log.WithPrefix(logKeyDB).WithFields(map[string]interface{}{
|
||||||
logKeyId: e.id,
|
logKeyId: e.id,
|
||||||
logKeySpan: span.SpanContext().SpanID.String(),
|
|
||||||
logKeyTrace: span.SpanContext().TraceID.String(),
|
|
||||||
logKeyStack: string(debug.Stack()),
|
logKeyStack: string(debug.Stack()),
|
||||||
logKeyFibre: ctx.Value(ctxKeyFibre).(*fibre.Context),
|
logKeyFibre: ctx.Value(ctxKeyFibre).(*fibre.Context),
|
||||||
}).Errorln(err)
|
}).Errorln(err)
|
||||||
|
@ -138,13 +128,6 @@ func (e *executor) conduct(ctx context.Context, stm sql.Statement) {
|
||||||
var rsp *Response
|
var rsp *Response
|
||||||
var res []interface{}
|
var res []interface{}
|
||||||
|
|
||||||
// Create a new trace span so we can analyse
|
|
||||||
// the execution time of this method, and
|
|
||||||
// detect problems with long-running queries.
|
|
||||||
|
|
||||||
ctx, span := trc.Start(ctx, "db::conduct")
|
|
||||||
defer span.End()
|
|
||||||
|
|
||||||
// If we are not inside a global transaction
|
// If we are not inside a global transaction
|
||||||
// then reset the error to nil so that the
|
// then reset the error to nil so that the
|
||||||
// next statement is not ignored.
|
// next statement is not ignored.
|
||||||
|
@ -215,8 +198,6 @@ func (e *executor) conduct(ctx context.Context, stm sql.Statement) {
|
||||||
logKeyKind: ctx.Value(ctxKeyKind),
|
logKeyKind: ctx.Value(ctxKeyKind),
|
||||||
logKeyVars: ctx.Value(ctxKeyVars),
|
logKeyVars: ctx.Value(ctxKeyVars),
|
||||||
logKeyTime: time.Since(e.time).String(),
|
logKeyTime: time.Since(e.time).String(),
|
||||||
logKeySpan: span.SpanContext().SpanID.String(),
|
|
||||||
logKeyTrace: span.SpanContext().TraceID.String(),
|
|
||||||
logKeyFibre: ctx.Value(ctxKeyFibre).(*fibre.Context),
|
logKeyFibre: ctx.Value(ctxKeyFibre).(*fibre.Context),
|
||||||
}).Debugln(stm)
|
}).Debugln(stm)
|
||||||
}
|
}
|
||||||
|
@ -229,8 +210,6 @@ func (e *executor) conduct(ctx context.Context, stm sql.Statement) {
|
||||||
logKeyKind: ctx.Value(ctxKeyKind),
|
logKeyKind: ctx.Value(ctxKeyKind),
|
||||||
logKeyVars: ctx.Value(ctxKeyVars),
|
logKeyVars: ctx.Value(ctxKeyVars),
|
||||||
logKeyTime: time.Since(e.time).String(),
|
logKeyTime: time.Since(e.time).String(),
|
||||||
logKeySpan: span.SpanContext().SpanID.String(),
|
|
||||||
logKeyTrace: span.SpanContext().TraceID.String(),
|
|
||||||
logKeyFibre: ctx.Value(ctxKeyFibre).(*fibre.Context),
|
logKeyFibre: ctx.Value(ctxKeyFibre).(*fibre.Context),
|
||||||
logKeyError: detail(e.err),
|
logKeyError: detail(e.err),
|
||||||
}).Errorln(stm)
|
}).Errorln(stm)
|
||||||
|
@ -270,13 +249,6 @@ func (e *executor) operate(ctx context.Context, stm sql.Statement) (res []interf
|
||||||
var trw bool
|
var trw bool
|
||||||
var canc context.CancelFunc
|
var canc context.CancelFunc
|
||||||
|
|
||||||
// Create a new trace span so we can analyse
|
|
||||||
// the execution time of this method, and
|
|
||||||
// detect problems with long-running queries.
|
|
||||||
|
|
||||||
ctx, span := trc.Start(ctx, "db::operate")
|
|
||||||
defer span.End()
|
|
||||||
|
|
||||||
// If we are not inside a global transaction
|
// If we are not inside a global transaction
|
||||||
// then grab a new transaction, ensuring that
|
// then grab a new transaction, ensuring that
|
||||||
// it is closed at the end.
|
// it is closed at the end.
|
||||||
|
|
9
main.go
9
main.go
|
@ -21,10 +21,7 @@ import (
|
||||||
|
|
||||||
"github.com/pkg/profile"
|
"github.com/pkg/profile"
|
||||||
|
|
||||||
"cloud.google.com/go/profiler"
|
|
||||||
|
|
||||||
"github.com/abcum/surreal/cli"
|
"github.com/abcum/surreal/cli"
|
||||||
"github.com/abcum/surreal/util/build"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
@ -40,12 +37,6 @@ func main() {
|
||||||
|
|
||||||
runtime.GOMAXPROCS(runtime.NumCPU())
|
runtime.GOMAXPROCS(runtime.NumCPU())
|
||||||
|
|
||||||
profiler.Start(profiler.Config{
|
|
||||||
ProjectID: "surreal-io",
|
|
||||||
Service: "surreal",
|
|
||||||
ServiceVersion: build.GetInfo().Ver,
|
|
||||||
})
|
|
||||||
|
|
||||||
cli.Init()
|
cli.Init()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
61
trc/main.go
61
trc/main.go
|
@ -1,61 +0,0 @@
|
||||||
// Copyright © 2016 Abcum Ltd
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
package trc
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
|
|
||||||
"go.opencensus.io/trace"
|
|
||||||
|
|
||||||
"github.com/abcum/surreal/cnf"
|
|
||||||
"github.com/abcum/surreal/log"
|
|
||||||
|
|
||||||
"contrib.go.opencensus.io/exporter/stackdriver"
|
|
||||||
)
|
|
||||||
|
|
||||||
func Setup(opts *cnf.Options) (err error) {
|
|
||||||
|
|
||||||
log.WithPrefix("log").Infof("Starting open tracing framework")
|
|
||||||
|
|
||||||
var exporter *stackdriver.Exporter
|
|
||||||
|
|
||||||
opt := stackdriver.Options{
|
|
||||||
ProjectID: "surreal-io",
|
|
||||||
OnError: func(error) {},
|
|
||||||
}
|
|
||||||
|
|
||||||
exporter, err = stackdriver.NewExporter(opt)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
err = exporter.StartMetricsExporter()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
trace.ApplyConfig(trace.Config{
|
|
||||||
DefaultSampler: trace.AlwaysSample(),
|
|
||||||
})
|
|
||||||
|
|
||||||
trace.RegisterExporter(exporter)
|
|
||||||
|
|
||||||
return
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func Start(ctx context.Context, name string) (context.Context, *trace.Span) {
|
|
||||||
return trace.StartSpan(ctx, name)
|
|
||||||
}
|
|
Loading…
Reference in a new issue