mirror of
https://github.com/hanzoai/otel-collector.git
synced 2026-11-02 13:34:59 +00:00
- imports: ClickHouse/ch-go, clickhouse-go/v2, srikanthccv/ClickHouse-go-mock
-> github.com/hanzo-ds/{native,go,mock} (require, clean semver, NO replace)
- identifiers/aliases/type-names/config-keys/type-IDs: clickhouse -> datastore
(receiver dir clickhousesystemtablesreceiver -> datastoresystemtablesreceiver)
- DSN scheme clickhouse:// -> datastore:// (driver treats non-http/https as Native)
- removed the go.opencensus.io version-pin replace (require-pinned instead)
- kept: real external refs (github.com/ClickHouse, clickhouse.com docs) and the
hanzo-ds/mock test API (NewClickHouseNative) pending the mock's own rename
Full ./... build passes. 0 replace directives, 0 signoz.
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())
|
|
}
|