From 97948259ec72872476dd51ddcbfc6cd97f3bb0e0 Mon Sep 17 00:00:00 2001 From: Tyler Yahn Date: Sun, 28 Apr 2024 10:07:43 -0700 Subject: [PATCH] Use empty resource when RecordFactory.Resource nil (#5264) --- sdk/log/logtest/factory.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/sdk/log/logtest/factory.go b/sdk/log/logtest/factory.go index 850869141d5..86b75d89317 100644 --- a/sdk/log/logtest/factory.go +++ b/sdk/log/logtest/factory.go @@ -67,8 +67,13 @@ func (b RecordFactory) NewRecord() sdklog.Record { attributeCountLimit = len(b.Attributes) } + res := b.Resource + if res == nil { + res = resource.Empty() + } + provider := sdklog.NewLoggerProvider( - sdklog.WithResource(b.Resource), + sdklog.WithResource(res), sdklog.WithAttributeCountLimit(attributeCountLimit), sdklog.WithAttributeValueLengthLimit(-1), sdklog.WithProcessor(p),