Skip to content

Commit

Permalink
Specify tracing port using opion (#80)
Browse files Browse the repository at this point in the history
Also specfy avid-tools version

AB#8760
  • Loading branch information
eccles authored Aug 6, 2024
1 parent 79d104e commit 7d74b38
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 3 deletions.
1 change: 1 addition & 0 deletions .env.tools
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export TOOLS_BUILDNUMBER=20240805.1
36 changes: 33 additions & 3 deletions startup/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,43 @@ import (
"github.com/datatrails/go-datatrails-common/tracing"
)

const (
restProxyPort = "RESTPROXY_PORT"
port = "PORT"
)

type runOptions struct {
portName string
}

type RunOption func(*runOptions)

func UseRestproxyTracingPort() RunOption {
return func(o *runOptions) {
o.portName = restProxyPort
}
}

func NoTracingPort() RunOption {
return func(o *runOptions) {
o.portName = ""
}
}

type Runner func(logger.Logger) error

// defers do not work in main() because of the os.Exit(
func Run(serviceName string, portName string, run Runner) {
func Run(serviceName string, run Runner, opts ...RunOption) {

logger.New(environment.GetLogLevel())
log := logger.Sugar.WithServiceName(serviceName)

o := runOptions{portName: port}

for _, opt := range opts {
opt(&o)
}

exitCode := func() int {
var exitCode int
var err error
Expand All @@ -33,8 +63,8 @@ func Run(serviceName string, portName string, run Runner) {
// log the useful kubernetes go configuration
log.Infof("Go Configuration: %+v", k8Config)

if portName != "" {
closer := tracing.NewTracer(log, portName)
if o.portName != "" {
closer := tracing.NewTracer(log, o.portName)
if closer != nil {
defer closer.Close()
}
Expand Down

0 comments on commit 7d74b38

Please sign in to comment.