mirror of
https://github.com/open-telemetry/opentelemetry-go.git
synced 2024-11-24 08:22:25 +02:00
log/logtest: Add Attributes to ScopeRecords (#5927)
Towards https://github.com/open-telemetry/opentelemetry-go/issues/3368
This commit is contained in:
parent
6a2f7de06d
commit
4f94b1e661
@ -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 `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)
|
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 `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
|
### Fixed
|
||||||
|
|
||||||
|
@ -7,6 +7,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
|
"go.opentelemetry.io/otel/attribute"
|
||||||
"go.opentelemetry.io/otel/log"
|
"go.opentelemetry.io/otel/log"
|
||||||
"go.opentelemetry.io/otel/log/embedded"
|
"go.opentelemetry.io/otel/log/embedded"
|
||||||
)
|
)
|
||||||
@ -66,6 +67,8 @@ type ScopeRecords struct {
|
|||||||
Version string
|
Version string
|
||||||
// SchemaURL of the telemetry emitted by the scope.
|
// SchemaURL of the telemetry emitted by the scope.
|
||||||
SchemaURL string
|
SchemaURL string
|
||||||
|
// Attributes of the telemetry emitted by the scope.
|
||||||
|
Attributes attribute.Set
|
||||||
|
|
||||||
// Records are the log records, and their associated context this
|
// Records are the log records, and their associated context this
|
||||||
// instrumentation scope recorded.
|
// instrumentation scope recorded.
|
||||||
@ -104,9 +107,10 @@ func (r *Recorder) Logger(name string, opts ...log.LoggerOption) log.Logger {
|
|||||||
|
|
||||||
nl := &logger{
|
nl := &logger{
|
||||||
scopeRecord: &ScopeRecords{
|
scopeRecord: &ScopeRecords{
|
||||||
Name: name,
|
Name: name,
|
||||||
Version: cfg.InstrumentationVersion(),
|
Version: cfg.InstrumentationVersion(),
|
||||||
SchemaURL: cfg.SchemaURL(),
|
SchemaURL: cfg.SchemaURL(),
|
||||||
|
Attributes: cfg.InstrumentationAttributes(),
|
||||||
},
|
},
|
||||||
enabledFn: r.enabledFn,
|
enabledFn: r.enabledFn,
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,7 @@ import (
|
|||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
|
||||||
|
"go.opentelemetry.io/otel/attribute"
|
||||||
"go.opentelemetry.io/otel/log"
|
"go.opentelemetry.io/otel/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -37,13 +38,15 @@ func TestRecorderLogger(t *testing.T) {
|
|||||||
loggerOptions: []log.LoggerOption{
|
loggerOptions: []log.LoggerOption{
|
||||||
log.WithInstrumentationVersion("logtest v42"),
|
log.WithInstrumentationVersion("logtest v42"),
|
||||||
log.WithSchemaURL("https://example.com"),
|
log.WithSchemaURL("https://example.com"),
|
||||||
|
log.WithInstrumentationAttributes(attribute.String("foo", "bar")),
|
||||||
},
|
},
|
||||||
|
|
||||||
wantLogger: &logger{
|
wantLogger: &logger{
|
||||||
scopeRecord: &ScopeRecords{
|
scopeRecord: &ScopeRecords{
|
||||||
Name: "test",
|
Name: "test",
|
||||||
Version: "logtest v42",
|
Version: "logtest v42",
|
||||||
SchemaURL: "https://example.com",
|
SchemaURL: "https://example.com",
|
||||||
|
Attributes: attribute.NewSet(attribute.String("foo", "bar")),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user