mirror of
https://github.com/hanzoai/otel-collector.git
synced 2026-11-02 13:34:59 +00:00
- add metadata.yaml for all relevant components and use metadata - fix the go routine leaks in component code and tests - add TODO for handling errors wherever they are unchecked or not handled so the behaviour doesn't change - address lint for the most part (so we can enable it soon) except the metricexporter that is due to be deleted and semconv which I don't want to touch right now - other changes required for bump breaking changes to pay attention to - telemetry config, address and level removed and readers should be used - change in attributes for telemetry - metrics at detailed level - failures in embedded config (addressed) --------- Co-authored-by: Nityananda Gohain <[email protected]>
65 lines
1.9 KiB
Go
65 lines
1.9 KiB
Go
// Code generated by mdatagen. DO NOT EDIT.
|
|
|
|
package metadata
|
|
|
|
import (
|
|
"github.com/stretchr/testify/assert"
|
|
"go.opentelemetry.io/collector/pdata/pcommon"
|
|
"go.opentelemetry.io/collector/pdata/plog"
|
|
"go.opentelemetry.io/collector/receiver/receivertest"
|
|
"go.uber.org/zap"
|
|
"go.uber.org/zap/zaptest/observer"
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
func TestLogsBuilderAppendLogRecord(t *testing.T) {
|
|
observedZapCore, _ := observer.New(zap.WarnLevel)
|
|
settings := receivertest.NewNopSettings(receivertest.NopType)
|
|
settings.Logger = zap.New(observedZapCore)
|
|
lb := NewLogsBuilder(settings)
|
|
|
|
res := pcommon.NewResource()
|
|
|
|
// append the first log record
|
|
lr := plog.NewLogRecord()
|
|
lr.SetTimestamp(pcommon.NewTimestampFromTime(time.Now()))
|
|
lr.Attributes().PutStr("type", "log")
|
|
lr.Body().SetStr("the first log record")
|
|
|
|
// append the second log record
|
|
lr2 := plog.NewLogRecord()
|
|
lr2.SetTimestamp(pcommon.NewTimestampFromTime(time.Now()))
|
|
lr2.Attributes().PutStr("type", "event")
|
|
lr2.Body().SetStr("the second log record")
|
|
|
|
lb.AppendLogRecord(lr)
|
|
lb.AppendLogRecord(lr2)
|
|
|
|
logs := lb.Emit(WithLogsResource(res))
|
|
assert.Equal(t, 1, logs.ResourceLogs().Len())
|
|
|
|
rl := logs.ResourceLogs().At(0)
|
|
assert.Equal(t, 1, rl.ScopeLogs().Len())
|
|
|
|
sl := rl.ScopeLogs().At(0)
|
|
assert.Equal(t, ScopeName, sl.Scope().Name())
|
|
assert.Equal(t, lb.buildInfo.Version, sl.Scope().Version())
|
|
|
|
assert.Equal(t, 2, sl.LogRecords().Len())
|
|
|
|
attrVal, ok := sl.LogRecords().At(0).Attributes().Get("type")
|
|
assert.True(t, ok)
|
|
assert.Equal(t, "log", attrVal.Str())
|
|
|
|
assert.Equal(t, pcommon.ValueTypeStr, sl.LogRecords().At(0).Body().Type())
|
|
assert.Equal(t, "the first log record", sl.LogRecords().At(0).Body().Str())
|
|
|
|
attrVal, ok = sl.LogRecords().At(1).Attributes().Get("type")
|
|
assert.True(t, ok)
|
|
assert.Equal(t, "event", attrVal.Str())
|
|
|
|
assert.Equal(t, pcommon.ValueTypeStr, sl.LogRecords().At(1).Body().Type())
|
|
assert.Equal(t, "the second log record", sl.LogRecords().At(1).Body().Str())
|
|
}
|