-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Replace Record lim methods with DroppedAttributes * Add changelog entry * Add TestRecordDroppedAttributes * Add TestRecordCompactAttr * Add an indexPool * Fix gramatical error * Apply feedback Reduce indentation level. * Apply feedback Comment compactAttr and deduplicate. * Deduplicate all attributes when added * Comment why head is not used * Clarify comments * Move TestAllocationLimits to new file Do not run this test when the race detector is on. * Comment follow-up task
- Loading branch information
Showing
6 changed files
with
347 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
//go:build !race | ||
|
||
package log | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
"time" | ||
|
||
"github.com/stretchr/testify/assert" | ||
|
||
"go.opentelemetry.io/otel/log" | ||
"go.opentelemetry.io/otel/sdk/instrumentation" | ||
) | ||
|
||
func TestAllocationLimits(t *testing.T) { | ||
// This test is not run with a race detector. The sync.Pool used by parts | ||
// of the SDK has memory optimizations removed for the race detector. Do | ||
// not test performance of the SDK in that state. | ||
|
||
const runs = 10 | ||
|
||
logger := newLogger(NewLoggerProvider(), instrumentation.Scope{}) | ||
|
||
r := log.Record{} | ||
r.SetTimestamp(time.Date(2000, time.January, 1, 0, 0, 0, 0, time.UTC)) | ||
r.SetObservedTimestamp(time.Date(2000, time.January, 1, 0, 0, 0, 0, time.UTC)) | ||
r.SetBody(log.StringValue("testing body value")) | ||
r.SetSeverity(log.SeverityInfo) | ||
r.SetSeverityText("testing text") | ||
|
||
r.AddAttributes( | ||
log.String("k1", "str"), | ||
log.Float64("k2", 1.0), | ||
log.Int("k3", 2), | ||
log.Bool("k4", true), | ||
log.Bytes("k5", []byte{1}), | ||
) | ||
|
||
assert.Equal(t, 0.0, testing.AllocsPerRun(runs, func() { | ||
logger.newRecord(context.Background(), r) | ||
}), "newRecord") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.