You've already forked opentelemetry-go
mirror of
https://github.com/open-telemetry/opentelemetry-go.git
synced 2025-08-10 22:31:50 +02:00
sdk/log: Record.Resource to return *resource.Resource (#6864)
Fixes https://github.com/open-telemetry/opentelemetry-go/issues/6863 From https://pkg.go.dev/go.opentelemetry.io/otel/sdk/resource#Resource: > Resource is an immutable object > [...] > Resources should be passed and stored as pointers (`*resource.Resource`) In all other places the exported API uses `*resource.Resource` and not `resource.Resource`.
This commit is contained in:
@@ -71,7 +71,7 @@ func TestRecordFactory(t *testing.T) {
|
||||
assert.Equal(t, spanID, got.SpanID())
|
||||
assert.Equal(t, traceFlags, got.TraceFlags())
|
||||
assert.Equal(t, scope, got.InstrumentationScope())
|
||||
assert.Equal(t, *r, got.Resource())
|
||||
assert.Equal(t, r, got.Resource())
|
||||
}
|
||||
|
||||
func TestRecordFactoryMultiple(t *testing.T) {
|
||||
|
@@ -387,11 +387,8 @@ func (r *Record) SetTraceFlags(flags trace.TraceFlags) {
|
||||
}
|
||||
|
||||
// Resource returns the entity that collected the log.
|
||||
func (r *Record) Resource() resource.Resource {
|
||||
if r.resource == nil {
|
||||
return *resource.Empty()
|
||||
}
|
||||
return *r.resource
|
||||
func (r *Record) Resource() *resource.Resource {
|
||||
return r.resource
|
||||
}
|
||||
|
||||
// InstrumentationScope returns the scope that the Logger was created with.
|
||||
|
@@ -125,7 +125,7 @@ func TestRecordResource(t *testing.T) {
|
||||
res := resource.NewSchemaless(attribute.Bool("key", true))
|
||||
r.resource = res
|
||||
got := r.Resource()
|
||||
assert.True(t, res.Equal(&got))
|
||||
assert.Equal(t, res, got)
|
||||
}
|
||||
|
||||
func TestRecordInstrumentationScope(t *testing.T) {
|
||||
|
Reference in New Issue
Block a user