You've already forked opentelemetry-go
							
							
				mirror of
				https://github.com/open-telemetry/opentelemetry-go.git
				synced 2025-10-31 00:07:40 +02:00 
			
		
		
		
	feat: opt for concatenation instead of using fmt.Sprintf (#5286)
* feat: opt for concatenation instead of using fmt.Sprintf * Update Changelog --------- Co-authored-by: Robert Pająk <pellared@hotmail.com> Co-authored-by: Damien Mathieu <damien.mathieu@elastic.co>
This commit is contained in:
		| @@ -22,6 +22,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm | ||||
| - Apply the value length limits to `Record` attributes in `go.opentelemetry.io/otel/sdk/log`. (#5230) | ||||
| - De-duplicate map attributes added to a `Record` in `go.opentelemetry.io/otel/sdk/log`. (#5230) | ||||
| - The `go.opentelemetry.io/otel/exporters/stdout/stdoutlog` exporter won't print `AttributeValueLengthLimit` and `AttributeCountLimit` fields now, instead it prints the `DroppedAttributes` field. (#5272) | ||||
| - Improved performance in the `Stringer` implementation of `go.opentelemetry.io/otel/baggage.Member` by reducing the number of allocations. (#5286) | ||||
|  | ||||
| ## [1.26.0/0.48.0/0.2.0-alpha] 2024-04-24 | ||||
|  | ||||
|   | ||||
| @@ -335,9 +335,9 @@ func (m Member) String() string { | ||||
| 	// A key is just an ASCII string. A value is restricted to be | ||||
| 	// US-ASCII characters excluding CTLs, whitespace, | ||||
| 	// DQUOTE, comma, semicolon, and backslash. | ||||
| 	s := fmt.Sprintf("%s%s%s", m.key, keyValueDelimiter, valueEscape(m.value)) | ||||
| 	s := m.key + keyValueDelimiter + valueEscape(m.value) | ||||
| 	if len(m.properties) > 0 { | ||||
| 		s = fmt.Sprintf("%s%s%s", s, propertyDelimiter, m.properties.String()) | ||||
| 		s += propertyDelimiter + m.properties.String() | ||||
| 	} | ||||
| 	return s | ||||
| } | ||||
|   | ||||
| @@ -1027,3 +1027,18 @@ func BenchmarkValueEscape(b *testing.B) { | ||||
| 		}) | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func BenchmarkMemberString(b *testing.B) { | ||||
| 	alphabet := "abcdefghijklmnopqrstuvwxyz" | ||||
| 	props := make([]Property, len(alphabet)) | ||||
| 	for i, r := range alphabet { | ||||
| 		props[i] = Property{key: string(r)} | ||||
| 	} | ||||
| 	member, err := NewMember(alphabet, alphabet, props...) | ||||
| 	require.NoError(b, err) | ||||
| 	b.ReportAllocs() | ||||
| 	b.ResetTimer() | ||||
| 	for i := 0; i < b.N; i++ { | ||||
| 		_ = member.String() | ||||
| 	} | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user