mirror of
https://github.com/open-telemetry/opentelemetry-go.git
synced 2024-12-28 21:09:17 +02:00
5331939a74
This is a follow-up to the comments in https://github.com/open-telemetry/opentelemetry-go/pull/5468#discussion_r1624173196, introducing `logtest.AssertRecordEqual` so bridges can compare log records more easily. --------- Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
34 lines
721 B
Go
34 lines
721 B
Go
// Copyright The OpenTelemetry Authors
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
package logtest
|
|
|
|
import (
|
|
"testing"
|
|
"time"
|
|
|
|
"go.opentelemetry.io/otel/log"
|
|
)
|
|
|
|
func TestAssertRecord(t *testing.T) {
|
|
r1 := log.Record{}
|
|
r2 := log.Record{}
|
|
now := time.Now()
|
|
|
|
AssertRecordEqual(t, r1, r2)
|
|
|
|
r1.SetTimestamp(now)
|
|
r2.SetTimestamp(now)
|
|
r1.SetObservedTimestamp(now)
|
|
r2.SetObservedTimestamp(now)
|
|
r1.SetSeverity(log.SeverityTrace1)
|
|
r2.SetSeverity(log.SeverityTrace1)
|
|
r1.SetSeverityText("trace")
|
|
r2.SetSeverityText("trace")
|
|
r1.SetBody(log.StringValue("log body"))
|
|
r2.SetBody(log.StringValue("log body"))
|
|
r1.AddAttributes(log.Bool("attr", true))
|
|
r2.AddAttributes(log.Bool("attr", true))
|
|
AssertRecordEqual(t, r1, r2)
|
|
}
|