Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,12 @@ import (
"sync/atomic"
"time"

"github.com/hashicorp/memberlist"

ucli "github.com/actiontech/dtle/internal/client"
uconf "github.com/actiontech/dtle/internal/config"
ulog "github.com/actiontech/dtle/internal/logger"
umodel "github.com/actiontech/dtle/internal/models"
usrv "github.com/actiontech/dtle/internal/server"
"github.com/hashicorp/memberlist"
)

// Agent is a long running daemon that is used to run both
Expand Down
41 changes: 38 additions & 3 deletions agent/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"fmt"
"io"
"log"
"net/http"
"os"
"os/signal"
"path/filepath"
Expand All @@ -19,16 +20,17 @@ import (
"strings"
"syscall"
"time"
"net/http"

"github.com/actiontech/dtle/internal/g"

ulog "github.com/actiontech/dtle/internal/logger"
"github.com/armon/go-metrics"
"github.com/armon/go-metrics/prometheus"
"github.com/mitchellh/cli"

ulog "github.com/actiontech/dtle/internal/logger"
opentracing "github.com/opentracing/opentracing-go"
"github.com/rakyll/autopprof"
jaeger "github.com/uber/jaeger-client-go"
jaegercnf "github.com/uber/jaeger-client-go/config"

report "github.com/ikarishinjieva/golang-live-coverage-report/pkg"
)
Expand Down Expand Up @@ -94,6 +96,8 @@ func (c *Command) readConfig() *Config {
flags.IntVar(&cmdConfig.CoverageReportPort, "coverage-report-port", 0, "")
flags.StringVar(&cmdConfig.CoverageReportRawCodeDir, "coverage-report-raw-code-dir", "/usr/lib/dtle", "")
flags.StringVar(&cmdConfig.NodeName, "node", "", "")
flags.StringVar(&cmdConfig.JaegerAgentAddress, "jaeger-agent-address", "", "")
flags.StringVar(&cmdConfig.JaegerAgentPort, "jaeger-agent-port", "", "")

if err := flags.Parse(c.args); err != nil {
return nil
Expand Down Expand Up @@ -248,6 +252,7 @@ func (c *Command) setupLoggers(config *Config) (io.Writer, error) {

// setupAgent is used to start the agent and various interfaces
func (c *Command) setupAgent(config *Config, logOutput io.Writer) error {

c.logger.Printf("Starting Dtle server...")
agent, err := NewAgent(config, logOutput, c.logger)
if err != nil {
Expand Down Expand Up @@ -275,6 +280,36 @@ func (c *Command) Run(args []string) int {
if config == nil {
return 1
}
if config.JaegerAgentAddress != "" && config.JaegerAgentPort != "" {
cfg := jaegercnf.Configuration{
Sampler: &jaegercnf.SamplerConfig{
Type: "const",
Param: 1,
},
ServiceName: "dtle",
Reporter: &jaegercnf.ReporterConfig{
LogSpans: true,
BufferFlushInterval: 1 * time.Second,
},
}
sender, err := jaeger.NewUDPTransport(config.JaegerAgentAddress+":"+config.JaegerAgentPort, 0)
if err != nil {
return 1
}

reporter := jaeger.NewRemoteReporter(sender)
// Initialize tracer with a logger and a metrics factory
tracer, closer, err := cfg.NewTracer(
jaegercnf.Reporter(reporter),
)

/*tracer, closer, err := cfg.NewTracer()*/
if err != nil {
return 1
}
opentracing.SetGlobalTracer(tracer)
defer closer.Close()
}

// Setup the log outputs
logOutput, err := c.setupLoggers(config)
Expand Down
31 changes: 22 additions & 9 deletions agent/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,11 @@ type Config struct {

// CoverageReportRawCodeDir is the root deploy directory of coverage report raw code
CoverageReportRawCodeDir string `mapstructure:"coverage_report_raw_code_dir"`

//jaegerAgentAddress is jaeger tracing Data reporting address
JaegerAgentAddress string `mapstructure:"jaeger_agent_address"`
//jaegerAgentPort is jaeger tracing Data reporting port
JaegerAgentPort string `mapstructure:"jaeger_agent_port"`
}

// ClientConfig is configuration specific to the client mode
Expand Down Expand Up @@ -252,15 +257,17 @@ type Node struct {
// DefaultConfig is a the baseline configuration for Udup
func DefaultConfig() *Config {
return &Config{
LogLevel: "INFO",
LogFile: "/var/log/dtle/dtle.log",
LogToStdout: false,
PprofSwitch: false,
PprofTime: 0,
PidFile: "/var/run/dtle/dtle.pid",
Region: "global",
Datacenter: "dc1",
BindAddr: "0.0.0.0",
LogLevel: "INFO",
LogFile: "/var/log/dtle/dtle.log",
LogToStdout: false,
PprofSwitch: false,
PprofTime: 0,
PidFile: "/var/run/dtle/dtle.pid",
Region: "global",
Datacenter: "dc1",
BindAddr: "0.0.0.0",
JaegerAgentAddress: "",
JaegerAgentPort: "",
Ports: &Ports{
HTTP: 8190,
RPC: 8191,
Expand Down Expand Up @@ -376,6 +383,12 @@ func (c *Config) Merge(b *Config) *Config {
if b.LeaveOnTerm {
result.LeaveOnTerm = true
}
if b.JaegerAgentAddress != "" {
result.JaegerAgentAddress = b.JaegerAgentAddress
}
if b.JaegerAgentPort != "" {
result.JaegerAgentPort = b.JaegerAgentPort
}

// Apply the metric config
if result.Metric == nil && b.Metric != nil {
Expand Down
2 changes: 2 additions & 0 deletions agent/config_parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ func parseConfig(result *Config, list *ast.ObjectList) error {
"consul",
"http_api_response_headers",
"dtle_schema_name",
"jaeger_agent_address",
"jaeger_agent_port",
}
if err := checkHCLKeys(list, valid); err != nil {
return multierror.Prefix(err, "config:")
Expand Down
9 changes: 2 additions & 7 deletions cmd/dtle/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,12 @@ import (
"fmt"
"io/ioutil"
"log"
"os"

"github.com/mitchellh/cli"

_ "net/http/pprof"
"os"

"github.com/actiontech/dtle/agent"
"github.com/actiontech/dtle/cmd/dtle/command"
"github.com/mitchellh/cli"
)

// The git commit that was compiled. This will be filled in by the compiler.
Expand All @@ -33,9 +31,6 @@ func main() {

func realMain() int {
log.SetOutput(ioutil.Discard)

// Get the command line args. We shortcut "--version" and "-v" to
// just show the version.
args := os.Args[1:]
for _, arg := range args {
if arg == "-v" || arg == "--version" {
Expand Down
Empty file added git
Empty file.
Loading