{"modulePath":"github.com/AlaudaDevops/pkg","version":"v0.14.0","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package tracing\n\nPackage tracing contains tracing related functions.\n\n## Functions\n\n```go\nfunc ConfigMapName() string\n```\nConfigMapName gets the name of the tracing ConfigMap\n\n```go\nfunc RestfulFilter(serviceName string, ignorePaths ...string) restful.FilterFunction\n```\nRestfulFilter Set the tracing middleware for go-restful web service framework. If ignorePaths param is specified, these paths will not be sampled.\n\n```go\nfunc SetupDynamicPublishing(tracing *Tracing, configMapWatcher configmap.DefaultingWatcher) error\n```\nSetupDynamicPublishing sets up trace publishing for the process, by watching a ConfigMap for the configuration. Note that other pieces still need to generate the traces, this just ensures that if generated, they are collected appropriately. This is normally done by using tracing.HTTPSpanMiddleware as a middleware HTTP handler. The configuration will be dynamically updated when the ConfigMap is updated.\n\n```go\nfunc WrapTransport(rt http.RoundTripper) http.RoundTripper\n```\nWrapTransport Wrap Transport for Tracing When rt is nil, default transport will be used\n\n```go\nfunc WrapTransportForRestyClient(client *resty.Client)\n```\nWrapTransportForRestyClient Specifically wrapped for the go-resty client for tracking Warning: Because some methods in go-resty (such as SetTLSClientConfig、SetProxy) rely on \\*http.Transport, this method must be called after initialization.\n\ncorrect example:\n\n\trestyClient := resty.New()\n\trestyClient.SetTLSClientConfig(\u0026tls.Config{\n\t\tInsecureSkipVerify: true,\n\t})\n\ttracing.WrapTransportForRestyClient(restyClient)\n\nwrong example:\n\n\t\t\trestyClient := resty.New()\n\t     tracing.WrapTransportForRestyClient(restyClient)\n\t\t\trestyClient.SetTLSClientConfig(\u0026tls.Config{\n\t\t\t\tInsecureSkipVerify: true,\n\t\t\t})\n\n## Types\n\n```go\ntype Config struct {\n\t// Enable Controls whether to enable tracing.\n\t// default false.\n\tEnable bool `json:\"enable\" yaml:\"enable\"`\n\n\t// SamplingRatio Control the rate of sampling.\n\t// SamplingRatio \u003e= 1 will always sample.\n\t// SamplingRatio \u003c= 0 will never sample.\n\t// default 0.\n\tSamplingRatio float64 `json:\"sampling_ratio\" yaml:\"samplingRatio\"`\n\n\t// Backend The type of exporter backend\n\tBackend ExporterBackend `json:\"backend\" yaml:\"backend\"`\n\n\t// Jaeger The configuration used by jaeger backend\n\tJaeger JaegerConfig `json:\"jaeger\" yaml:\"jaeger\"`\n\n\t// Zipkin The configuration used by zipkin backend\n\tZipkin ZipkinConfig `json:\"zipkin\" yaml:\"zipkin\"`\n\n\t// Custom The configuration used by custom backend\n\tCustom string `json:\"custom\" yaml:\"custom\"`\n}\n```\nConfig tracing config\n\n```go\ntype ExporterBackend string\n```\nExporterBackend Built-in supported export types\n\n```go\nvar (\n\tExporterBackendJaeger ExporterBackend = \"jaeger\"\n\tExporterBackendZipkin ExporterBackend = \"zipkin\"\n\tExporterBackendCustom ExporterBackend = \"custom\"\n)\n```\n\n```go\ntype ExporterConstructor func(config *Config) (trace.SpanExporter, error)\n```\nExporterConstructor Construct exporter by the specified config\n\n```go\ntype JaegerConfig struct {\n\t// Host The host of jaeger backend.\n\tHost string `json:\"host\" yaml:\"host\"`\n\n\t// Port the port of jaeger backend.\n\tPort string `json:\"port\" yaml:\"port\"`\n\n\t// MaxPacketSize The maximum UDP packet size for transport to the Jaeger agent.\n\tMaxPacketSize int `json:\"max_packet_size\" yaml:\"maxPacketSize\"`\n\n\t// DisableAttemptReconnecting Disable reconnecting udp client.\n\tDisableAttemptReconnecting bool `json:\"disable_attempt_reconnecting\" yaml:\"disableAttemptReconnecting\"`\n\n\t// AttemptReconnectInterval The interval between attempts to re resolve agent endpoint.\n\tAttemptReconnectInterval time.Duration `json:\"attempt_reconnect_interval\" yaml:\"attemptReconnectInterval\"`\n}\n```\nJaegerConfig The configuration used by Jaeger backend\n\n```go\ntype ResourceConstructor func(config *Config) (*resource.Resource, error)\n```\nResourceConstructor Construct resource by the specified config\n\n```go\ntype TraceOption func(tracing *Tracing)\n```\nTraceOption optional setting of Tracing instance\n\n```go\nfunc WithExporter(f ExporterConstructor) TraceOption\n```\nWithExporter Configures the exporter backend for \\`Tracing\\` instance.\n\n```go\nfunc WithResource(f ResourceConstructor) TraceOption\n```\nWithResource Configures the resource for \\`Tracing\\` instance.\n\n```go\nfunc WithServiceName(name string) TraceOption\n```\nWithServiceName Configures the service name for Tracing instance\n\n```go\nfunc WithTextMapPropagator(ops ...propagation.TextMapPropagator) TraceOption\n```\nWithTextMapPropagator Configures the propagator options for traceProvider\n\n```go\nfunc WithTraceProvider(f TraceProviderConstructor) TraceOption\n```\nWithTraceProvider Configures the TraceProvider for \\`Tracing\\` instance If \\`TraceProvider\\` is specified, \\`WithExporter\\` and \\`WithResource\\` function will not work.\n\n```go\nfunc WithTracerProviderOption(ops ...trace.TracerProviderOption) TraceOption\n```\nWithTracerProviderOption Configures the options for built-in traceProvider\n\n```go\ntype TraceProviderConstructor func(config *Config) (*trace.TracerProvider, error)\n```\nTraceProviderConstructor Construct \\`TraceProvider\\` by the specified config\n\n```go\ntype Tracing struct {\n\tServiceName   string\n\tConfigMapName string\n\n\tPropagators []propagation.TextMapPropagator\n\t// contains filtered or unexported fields\n}\n```\nTracing describe an entity that watching configuration file changes and maintain the global tracing.\n\n```go\nfunc NewTracing(logger *zap.SugaredLogger, ops ...TraceOption) *Tracing\n```\nNewTracing construct \\`Tracing\\` instance \\`TraceOption\\` can be used to customize settings.\n\n```go\nfunc (t *Tracing) ApplyConfig(cfg *Config)\n```\nApplyConfig Apply configuration and reinitialize global tracing. This method will be triggered when the configuration changes. If an error occurs, the initialization process will be skipped.\n\n```go\ntype Transport struct {\n\t*otelhttp.Transport\n\t// contains filtered or unexported fields\n}\n```\nTransport for tracing\n\n```go\nfunc (t *Transport) CancelRequest(req *http.Request)\n```\nCancelRequest cancels an in-flight request by closing its connection. It works when the original RoundTripper implementation canceler interface.\n\n```go\nfunc (t *Transport) RoundTrip(req *http.Request) (*http.Response, error)\n```\nRoundTrip creates a Span and propagates its context via the provided request's headers before handing the request to the configured base RoundTripper. The created span will end when the response body is closed or when a read from the body returns io.EOF.\n\n```go\ntype ZipkinConfig struct {\n\t// Url The collector url of zipkin backend\n\tUrl string `json:\"url\" yaml:\"url\"`\n}\n```\nZipkinConfig The configuration used by zipkin backend\n\n","path":"github.com/AlaudaDevops/pkg/tracing","name":"tracing","synopsis":"Package tracing contains tracing related functions.","isRedistributable":true}
