github.com/GuanceCloud/cliutils@v1.1.21/tracer/option.go (about)

     1  // Unless explicitly stated otherwise all files in this repository are licensed
     2  // under the MIT License.
     3  // This product includes software developed at Guance Cloud (https://www.guance.com/).
     4  // Copyright 2021-present Guance, Inc.
     5  
     6  package tracer
     7  
     8  import (
     9  	"net"
    10  )
    11  
    12  type StartOption func(t *Tracer)
    13  
    14  func WithTraceEnabled(enabled bool) StartOption {
    15  	return func(t *Tracer) {
    16  		t.TraceEnabled = enabled
    17  	}
    18  }
    19  
    20  func WithAgentAddr(host, port string) StartOption {
    21  	return func(t *Tracer) {
    22  		t.Host = host
    23  		t.Port = port
    24  		t.agentAddr = net.JoinHostPort(host, port)
    25  	}
    26  }
    27  
    28  func WithService(service string) StartOption {
    29  	return func(t *Tracer) {
    30  		t.Service = service
    31  	}
    32  }
    33  
    34  func WithVersion(version string) StartOption {
    35  	return func(t *Tracer) {
    36  		t.Version = version
    37  	}
    38  }
    39  
    40  func WithLogsStartup(startup bool) StartOption {
    41  	return func(t *Tracer) {
    42  		t.LogsStartup = startup
    43  	}
    44  }
    45  
    46  func WithDebug(debug bool) StartOption {
    47  	return func(t *Tracer) {
    48  		t.Debug = debug
    49  	}
    50  }
    51  
    52  func WithGlobalTag(key string, value interface{}) StartOption {
    53  	return func(t *Tracer) {
    54  		t.Tags[key] = value
    55  	}
    56  }
    57  
    58  func WithEnv(env string) StartOption {
    59  	return func(t *Tracer) {
    60  		t.Env = env
    61  	}
    62  }