mirror of
				https://github.com/superseriousbusiness/gotosocial.git
				synced 2025-10-30 23:52:26 -05:00 
			
		
		
		
	[chore] Update usage of OTEL libraries (#2725)
* otel to 1.24 * prometheus exporter to 0.46 * bunotel to 1.1.17 Also: * Use schemaless URL for metrics * Add software version to tracing schema
This commit is contained in:
		
					parent
					
						
							
								8e88ee8d9c
							
						
					
				
			
			
				commit
				
					
						5e871e81a8
					
				
			
		
					 126 changed files with 12940 additions and 2267 deletions
				
			
		
							
								
								
									
										113
									
								
								vendor/google.golang.org/grpc/resolver/map.go
									
										
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										113
									
								
								vendor/google.golang.org/grpc/resolver/map.go
									
										
									
										generated
									
									
										vendored
									
									
								
							|  | @ -136,3 +136,116 @@ func (a *AddressMap) Values() []any { | |||
| 	} | ||||
| 	return ret | ||||
| } | ||||
| 
 | ||||
| type endpointNode struct { | ||||
| 	addrs map[string]struct{} | ||||
| } | ||||
| 
 | ||||
| // Equal returns whether the unordered set of addrs are the same between the | ||||
| // endpoint nodes. | ||||
| func (en *endpointNode) Equal(en2 *endpointNode) bool { | ||||
| 	if len(en.addrs) != len(en2.addrs) { | ||||
| 		return false | ||||
| 	} | ||||
| 	for addr := range en.addrs { | ||||
| 		if _, ok := en2.addrs[addr]; !ok { | ||||
| 			return false | ||||
| 		} | ||||
| 	} | ||||
| 	return true | ||||
| } | ||||
| 
 | ||||
| func toEndpointNode(endpoint Endpoint) endpointNode { | ||||
| 	en := make(map[string]struct{}) | ||||
| 	for _, addr := range endpoint.Addresses { | ||||
| 		en[addr.Addr] = struct{}{} | ||||
| 	} | ||||
| 	return endpointNode{ | ||||
| 		addrs: en, | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| // EndpointMap is a map of endpoints to arbitrary values keyed on only the | ||||
| // unordered set of address strings within an endpoint. This map is not thread | ||||
| // safe, thus it is unsafe to access concurrently. Must be created via | ||||
| // NewEndpointMap; do not construct directly. | ||||
| type EndpointMap struct { | ||||
| 	endpoints map[*endpointNode]any | ||||
| } | ||||
| 
 | ||||
| // NewEndpointMap creates a new EndpointMap. | ||||
| func NewEndpointMap() *EndpointMap { | ||||
| 	return &EndpointMap{ | ||||
| 		endpoints: make(map[*endpointNode]any), | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| // Get returns the value for the address in the map, if present. | ||||
| func (em *EndpointMap) Get(e Endpoint) (value any, ok bool) { | ||||
| 	en := toEndpointNode(e) | ||||
| 	if endpoint := em.find(en); endpoint != nil { | ||||
| 		return em.endpoints[endpoint], true | ||||
| 	} | ||||
| 	return nil, false | ||||
| } | ||||
| 
 | ||||
| // Set updates or adds the value to the address in the map. | ||||
| func (em *EndpointMap) Set(e Endpoint, value any) { | ||||
| 	en := toEndpointNode(e) | ||||
| 	if endpoint := em.find(en); endpoint != nil { | ||||
| 		em.endpoints[endpoint] = value | ||||
| 		return | ||||
| 	} | ||||
| 	em.endpoints[&en] = value | ||||
| } | ||||
| 
 | ||||
| // Len returns the number of entries in the map. | ||||
| func (em *EndpointMap) Len() int { | ||||
| 	return len(em.endpoints) | ||||
| } | ||||
| 
 | ||||
| // Keys returns a slice of all current map keys, as endpoints specifying the | ||||
| // addresses present in the endpoint keys, in which uniqueness is determined by | ||||
| // the unordered set of addresses. Thus, endpoint information returned is not | ||||
| // the full endpoint data (drops duplicated addresses and attributes) but can be | ||||
| // used for EndpointMap accesses. | ||||
| func (em *EndpointMap) Keys() []Endpoint { | ||||
| 	ret := make([]Endpoint, 0, len(em.endpoints)) | ||||
| 	for en := range em.endpoints { | ||||
| 		var endpoint Endpoint | ||||
| 		for addr := range en.addrs { | ||||
| 			endpoint.Addresses = append(endpoint.Addresses, Address{Addr: addr}) | ||||
| 		} | ||||
| 		ret = append(ret, endpoint) | ||||
| 	} | ||||
| 	return ret | ||||
| } | ||||
| 
 | ||||
| // Values returns a slice of all current map values. | ||||
| func (em *EndpointMap) Values() []any { | ||||
| 	ret := make([]any, 0, len(em.endpoints)) | ||||
| 	for _, val := range em.endpoints { | ||||
| 		ret = append(ret, val) | ||||
| 	} | ||||
| 	return ret | ||||
| } | ||||
| 
 | ||||
| // find returns a pointer to the endpoint node in em if the endpoint node is | ||||
| // already present. If not found, nil is returned. The comparisons are done on | ||||
| // the unordered set of addresses within an endpoint. | ||||
| func (em EndpointMap) find(e endpointNode) *endpointNode { | ||||
| 	for endpoint := range em.endpoints { | ||||
| 		if e.Equal(endpoint) { | ||||
| 			return endpoint | ||||
| 		} | ||||
| 	} | ||||
| 	return nil | ||||
| } | ||||
| 
 | ||||
| // Delete removes the specified endpoint from the map. | ||||
| func (em *EndpointMap) Delete(e Endpoint) { | ||||
| 	en := toEndpointNode(e) | ||||
| 	if entry := em.find(en); entry != nil { | ||||
| 		delete(em.endpoints, entry) | ||||
| 	} | ||||
| } | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue