in xray/config.go [187:246]
func Configure(c Config) error {
globalCfg.Lock()
defer globalCfg.Unlock()
var errors exception.MultiError
if c.SamplingStrategy != nil {
globalCfg.samplingStrategy = c.SamplingStrategy
}
if c.Emitter != nil {
globalCfg.emitter = c.Emitter
}
daemonEndpoints, er := daemoncfg.GetDaemonEndpointsFromString(c.DaemonAddr)
if daemonEndpoints != nil {
globalCfg.daemonAddr = daemonEndpoints.UDPAddr
globalCfg.emitter.RefreshEmitterWithAddress(globalCfg.daemonAddr)
configureStrategy(globalCfg.samplingStrategy, daemonEndpoints)
} else if er != nil {
errors = append(errors, er)
}
if c.ExceptionFormattingStrategy != nil {
globalCfg.exceptionFormattingStrategy = c.ExceptionFormattingStrategy
}
if c.StreamingStrategy != nil {
globalCfg.streamingStrategy = c.StreamingStrategy
}
cms := os.Getenv("AWS_XRAY_CONTEXT_MISSING")
if cms != "" {
if cms == ctxmissing.RuntimeErrorStrategy {
cm := ctxmissing.NewDefaultRuntimeErrorStrategy()
globalCfg.contextMissingStrategy = cm
} else if cms == ctxmissing.LogErrorStrategy {
cm := ctxmissing.NewDefaultLogErrorStrategy()
globalCfg.contextMissingStrategy = cm
} else if cms == ctxmissing.IgnoreErrorStrategy {
cm := ctxmissing.NewDefaultIgnoreErrorStrategy()
globalCfg.contextMissingStrategy = cm
}
} else if c.ContextMissingStrategy != nil {
globalCfg.contextMissingStrategy = c.ContextMissingStrategy
}
if c.ServiceVersion != "" {
globalCfg.serviceVersion = c.ServiceVersion
}
switch len(errors) {
case 0:
return nil
case 1:
return errors[0]
default:
return errors
}
}