mirror of
				https://github.com/superseriousbusiness/gotosocial.git
				synced 2025-10-31 05:52:25 -05:00 
			
		
		
		
	[feature] Support OTLP HTTP, drop Jaeger (#2184)
* [feature] Add http trace exporter, drop Jaeger Jaeger supports ingesting traces using the OpenTelemetry gRPC or HTTP methods. The Jaeger project has deprecated the old jaeger transport. * Add support for submitting traces over HTTP * Drop support for the old Jaeger protocol * Upgrade the trace libraries to v1.17 Fixes: #2176 Fixes: #2179
This commit is contained in:
		
					parent
					
						
							
								916c6d07ba
							
						
					
				
			
			
				commit
				
					
						14ef098099
					
				
			
		
					 199 changed files with 12972 additions and 18581 deletions
				
			
		
							
								
								
									
										74
									
								
								vendor/google.golang.org/grpc/internal/resolver/dns/dns_resolver.go
									
										
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										74
									
								
								vendor/google.golang.org/grpc/internal/resolver/dns/dns_resolver.go
									
										
									
										generated
									
									
										vendored
									
									
								
							|  | @ -62,7 +62,8 @@ const ( | |||
| 	defaultPort       = "443" | ||||
| 	defaultDNSSvrPort = "53" | ||||
| 	golang            = "GO" | ||||
| 	// txtPrefix is the prefix string to be prepended to the host name for txt record lookup. | ||||
| 	// txtPrefix is the prefix string to be prepended to the host name for txt | ||||
| 	// record lookup. | ||||
| 	txtPrefix = "_grpc_config." | ||||
| 	// In DNS, service config is encoded in a TXT record via the mechanism | ||||
| 	// described in RFC-1464 using the attribute name grpc_config. | ||||
|  | @ -86,14 +87,14 @@ var ( | |||
| 	minDNSResRate = 30 * time.Second | ||||
| ) | ||||
| 
 | ||||
| var customAuthorityDialler = func(authority string) func(ctx context.Context, network, address string) (net.Conn, error) { | ||||
| 	return func(ctx context.Context, network, address string) (net.Conn, error) { | ||||
| var addressDialer = func(address string) func(context.Context, string, string) (net.Conn, error) { | ||||
| 	return func(ctx context.Context, network, _ string) (net.Conn, error) { | ||||
| 		var dialer net.Dialer | ||||
| 		return dialer.DialContext(ctx, network, authority) | ||||
| 		return dialer.DialContext(ctx, network, address) | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| var customAuthorityResolver = func(authority string) (netResolver, error) { | ||||
| var newNetResolver = func(authority string) (netResolver, error) { | ||||
| 	host, port, err := parseTarget(authority, defaultDNSSvrPort) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
|  | @ -103,7 +104,7 @@ var customAuthorityResolver = func(authority string) (netResolver, error) { | |||
| 
 | ||||
| 	return &net.Resolver{ | ||||
| 		PreferGo: true, | ||||
| 		Dial:     customAuthorityDialler(authorityWithPort), | ||||
| 		Dial:     addressDialer(authorityWithPort), | ||||
| 	}, nil | ||||
| } | ||||
| 
 | ||||
|  | @ -114,7 +115,8 @@ func NewBuilder() resolver.Builder { | |||
| 
 | ||||
| type dnsBuilder struct{} | ||||
| 
 | ||||
| // Build creates and starts a DNS resolver that watches the name resolution of the target. | ||||
| // Build creates and starts a DNS resolver that watches the name resolution of | ||||
| // the target. | ||||
| func (b *dnsBuilder) Build(target resolver.Target, cc resolver.ClientConn, opts resolver.BuildOptions) (resolver.Resolver, error) { | ||||
| 	host, port, err := parseTarget(target.Endpoint(), defaultPort) | ||||
| 	if err != nil { | ||||
|  | @ -143,7 +145,7 @@ func (b *dnsBuilder) Build(target resolver.Target, cc resolver.ClientConn, opts | |||
| 	if target.URL.Host == "" { | ||||
| 		d.resolver = defaultResolver | ||||
| 	} else { | ||||
| 		d.resolver, err = customAuthorityResolver(target.URL.Host) | ||||
| 		d.resolver, err = newNetResolver(target.URL.Host) | ||||
| 		if err != nil { | ||||
| 			return nil, err | ||||
| 		} | ||||
|  | @ -180,19 +182,22 @@ type dnsResolver struct { | |||
| 	ctx      context.Context | ||||
| 	cancel   context.CancelFunc | ||||
| 	cc       resolver.ClientConn | ||||
| 	// rn channel is used by ResolveNow() to force an immediate resolution of the target. | ||||
| 	// rn channel is used by ResolveNow() to force an immediate resolution of the | ||||
| 	// target. | ||||
| 	rn chan struct{} | ||||
| 	// wg is used to enforce Close() to return after the watcher() goroutine has finished. | ||||
| 	// Otherwise, data race will be possible. [Race Example] in dns_resolver_test we | ||||
| 	// replace the real lookup functions with mocked ones to facilitate testing. | ||||
| 	// If Close() doesn't wait for watcher() goroutine finishes, race detector sometimes | ||||
| 	// will warns lookup (READ the lookup function pointers) inside watcher() goroutine | ||||
| 	// has data race with replaceNetFunc (WRITE the lookup function pointers). | ||||
| 	// wg is used to enforce Close() to return after the watcher() goroutine has | ||||
| 	// finished. Otherwise, data race will be possible. [Race Example] in | ||||
| 	// dns_resolver_test we replace the real lookup functions with mocked ones to | ||||
| 	// facilitate testing. If Close() doesn't wait for watcher() goroutine | ||||
| 	// finishes, race detector sometimes will warns lookup (READ the lookup | ||||
| 	// function pointers) inside watcher() goroutine has data race with | ||||
| 	// replaceNetFunc (WRITE the lookup function pointers). | ||||
| 	wg                   sync.WaitGroup | ||||
| 	disableServiceConfig bool | ||||
| } | ||||
| 
 | ||||
| // ResolveNow invoke an immediate resolution of the target that this dnsResolver watches. | ||||
| // ResolveNow invoke an immediate resolution of the target that this | ||||
| // dnsResolver watches. | ||||
| func (d *dnsResolver) ResolveNow(resolver.ResolveNowOptions) { | ||||
| 	select { | ||||
| 	case d.rn <- struct{}{}: | ||||
|  | @ -220,8 +225,8 @@ func (d *dnsResolver) watcher() { | |||
| 
 | ||||
| 		var timer *time.Timer | ||||
| 		if err == nil { | ||||
| 			// Success resolving, wait for the next ResolveNow. However, also wait 30 seconds at the very least | ||||
| 			// to prevent constantly re-resolving. | ||||
| 			// Success resolving, wait for the next ResolveNow. However, also wait 30 | ||||
| 			// seconds at the very least to prevent constantly re-resolving. | ||||
| 			backoffIndex = 1 | ||||
| 			timer = newTimerDNSResRate(minDNSResRate) | ||||
| 			select { | ||||
|  | @ -231,7 +236,8 @@ func (d *dnsResolver) watcher() { | |||
| 			case <-d.rn: | ||||
| 			} | ||||
| 		} else { | ||||
| 			// Poll on an error found in DNS Resolver or an error received from ClientConn. | ||||
| 			// Poll on an error found in DNS Resolver or an error received from | ||||
| 			// ClientConn. | ||||
| 			timer = newTimer(backoff.DefaultExponential.Backoff(backoffIndex)) | ||||
| 			backoffIndex++ | ||||
| 		} | ||||
|  | @ -278,7 +284,8 @@ func (d *dnsResolver) lookupSRV() ([]resolver.Address, error) { | |||
| } | ||||
| 
 | ||||
| func handleDNSError(err error, lookupType string) error { | ||||
| 	if dnsErr, ok := err.(*net.DNSError); ok && !dnsErr.IsTimeout && !dnsErr.IsTemporary { | ||||
| 	dnsErr, ok := err.(*net.DNSError) | ||||
| 	if ok && !dnsErr.IsTimeout && !dnsErr.IsTemporary { | ||||
| 		// Timeouts and temporary errors should be communicated to gRPC to | ||||
| 		// attempt another DNS query (with backoff).  Other errors should be | ||||
| 		// suppressed (they may represent the absence of a TXT record). | ||||
|  | @ -307,10 +314,12 @@ func (d *dnsResolver) lookupTXT() *serviceconfig.ParseResult { | |||
| 		res += s | ||||
| 	} | ||||
| 
 | ||||
| 	// TXT record must have "grpc_config=" attribute in order to be used as service config. | ||||
| 	// TXT record must have "grpc_config=" attribute in order to be used as | ||||
| 	// service config. | ||||
| 	if !strings.HasPrefix(res, txtAttribute) { | ||||
| 		logger.Warningf("dns: TXT record %v missing %v attribute", res, txtAttribute) | ||||
| 		// This is not an error; it is the equivalent of not having a service config. | ||||
| 		// This is not an error; it is the equivalent of not having a service | ||||
| 		// config. | ||||
| 		return nil | ||||
| 	} | ||||
| 	sc := canaryingSC(strings.TrimPrefix(res, txtAttribute)) | ||||
|  | @ -352,9 +361,10 @@ func (d *dnsResolver) lookup() (*resolver.State, error) { | |||
| 	return &state, nil | ||||
| } | ||||
| 
 | ||||
| // formatIP returns ok = false if addr is not a valid textual representation of an IP address. | ||||
| // If addr is an IPv4 address, return the addr and ok = true. | ||||
| // If addr is an IPv6 address, return the addr enclosed in square brackets and ok = true. | ||||
| // formatIP returns ok = false if addr is not a valid textual representation of | ||||
| // an IP address. If addr is an IPv4 address, return the addr and ok = true. | ||||
| // If addr is an IPv6 address, return the addr enclosed in square brackets and | ||||
| // ok = true. | ||||
| func formatIP(addr string) (addrIP string, ok bool) { | ||||
| 	ip := net.ParseIP(addr) | ||||
| 	if ip == nil { | ||||
|  | @ -366,10 +376,10 @@ func formatIP(addr string) (addrIP string, ok bool) { | |||
| 	return "[" + addr + "]", true | ||||
| } | ||||
| 
 | ||||
| // parseTarget takes the user input target string and default port, returns formatted host and port info. | ||||
| // If target doesn't specify a port, set the port to be the defaultPort. | ||||
| // If target is in IPv6 format and host-name is enclosed in square brackets, brackets | ||||
| // are stripped when setting the host. | ||||
| // parseTarget takes the user input target string and default port, returns | ||||
| // formatted host and port info. If target doesn't specify a port, set the port | ||||
| // to be the defaultPort. If target is in IPv6 format and host-name is enclosed | ||||
| // in square brackets, brackets are stripped when setting the host. | ||||
| // examples: | ||||
| // target: "www.google.com" defaultPort: "443" returns host: "www.google.com", port: "443" | ||||
| // target: "ipv4-host:80" defaultPort: "443" returns host: "ipv4-host", port: "80" | ||||
|  | @ -385,12 +395,14 @@ func parseTarget(target, defaultPort string) (host, port string, err error) { | |||
| 	} | ||||
| 	if host, port, err = net.SplitHostPort(target); err == nil { | ||||
| 		if port == "" { | ||||
| 			// If the port field is empty (target ends with colon), e.g. "[::1]:", this is an error. | ||||
| 			// If the port field is empty (target ends with colon), e.g. "[::1]:", | ||||
| 			// this is an error. | ||||
| 			return "", "", errEndsWithColon | ||||
| 		} | ||||
| 		// target has port, i.e ipv4-host:port, [ipv6-host]:port, host-name:port | ||||
| 		if host == "" { | ||||
| 			// Keep consistent with net.Dial(): If the host is empty, as in ":80", the local system is assumed. | ||||
| 			// Keep consistent with net.Dial(): If the host is empty, as in ":80", | ||||
| 			// the local system is assumed. | ||||
| 			host = "localhost" | ||||
| 		} | ||||
| 		return host, port, nil | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue