1
0
mirror of https://github.com/open-telemetry/opentelemetry-go.git synced 2024-11-28 08:38:51 +02:00

log/logtest: Add Attributes to ScopeRecords (#5927)

Towards https://github.com/open-telemetry/opentelemetry-go/issues/3368
This commit is contained in:
Robert Pająk 2024-10-30 06:40:14 +01:00 committed by GitHub
parent 6a2f7de06d
commit 4f94b1e661
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 14 additions and 6 deletions

View File

@ -18,6 +18,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
- The `go.opentelemetry.io/otel/semconv/v1.27.0` package.
The package contains semantic conventions from the `v1.27.0` version of the OpenTelemetry Semantic Conventions. (#5894)
- Add `Attributes attribute.Set` field to `Scope` in `go.opentelemetry.io/otel/sdk/instrumentation`. (#5903)
- Add `Attributes attribute.Set` field to `ScopeRecords` in `go.opentelemetry.io/otel/log/logtest`. (#5927)
### Fixed

View File

@ -7,6 +7,7 @@ import (
"context"
"sync"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/log"
"go.opentelemetry.io/otel/log/embedded"
)
@ -66,6 +67,8 @@ type ScopeRecords struct {
Version string
// SchemaURL of the telemetry emitted by the scope.
SchemaURL string
// Attributes of the telemetry emitted by the scope.
Attributes attribute.Set
// Records are the log records, and their associated context this
// instrumentation scope recorded.
@ -107,6 +110,7 @@ func (r *Recorder) Logger(name string, opts ...log.LoggerOption) log.Logger {
Name: name,
Version: cfg.InstrumentationVersion(),
SchemaURL: cfg.SchemaURL(),
Attributes: cfg.InstrumentationAttributes(),
},
enabledFn: r.enabledFn,
}

View File

@ -10,6 +10,7 @@ import (
"github.com/stretchr/testify/assert"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/log"
)
@ -37,6 +38,7 @@ func TestRecorderLogger(t *testing.T) {
loggerOptions: []log.LoggerOption{
log.WithInstrumentationVersion("logtest v42"),
log.WithSchemaURL("https://example.com"),
log.WithInstrumentationAttributes(attribute.String("foo", "bar")),
},
wantLogger: &logger{
@ -44,6 +46,7 @@ func TestRecorderLogger(t *testing.T) {
Name: "test",
Version: "logtest v42",
SchemaURL: "https://example.com",
Attributes: attribute.NewSet(attribute.String("foo", "bar")),
},
},
},