2024-02-18 18:13:42 +02:00
|
|
|
// Copyright The OpenTelemetry Authors
|
2024-02-29 08:05:28 +02:00
|
|
|
// SPDX-License-Identifier: Apache-2.0
|
2024-02-18 18:13:42 +02:00
|
|
|
|
|
|
|
package log_test
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
|
|
|
|
"go.opentelemetry.io/otel/attribute"
|
|
|
|
"go.opentelemetry.io/otel/log"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestNewLoggerConfig(t *testing.T) {
|
|
|
|
version := "v1.1.1"
|
|
|
|
schemaURL := "https://opentelemetry.io/schemas/1.0.0"
|
|
|
|
attr := attribute.NewSet(
|
|
|
|
attribute.String("user", "alice"),
|
|
|
|
attribute.Bool("admin", true),
|
|
|
|
)
|
|
|
|
|
|
|
|
c := log.NewLoggerConfig(
|
|
|
|
log.WithInstrumentationVersion(version),
|
|
|
|
log.WithSchemaURL(schemaURL),
|
|
|
|
log.WithInstrumentationAttributes(attr.ToSlice()...),
|
|
|
|
)
|
|
|
|
|
|
|
|
assert.Equal(t, version, c.InstrumentationVersion(), "instrumentation version")
|
|
|
|
assert.Equal(t, schemaURL, c.SchemaURL(), "schema URL")
|
|
|
|
assert.Equal(t, attr, c.InstrumentationAttributes(), "instrumentation attributes")
|
|
|
|
}
|