Skip to content

Commit 7c87bb6

Browse files
committed
chore: rename logItem
1 parent 43b7812 commit 7c87bb6

File tree

4 files changed

+21
-15
lines changed

4 files changed

+21
-15
lines changed

interfaces.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -728,13 +728,13 @@ func (l *Log) ToEnvelopeItem() (*protocol.EnvelopeItem, error) {
728728
}, nil
729729
}
730730

731-
// ToLogPayload converts the Log to a protocol.LogPayload for batching.
732-
func (l *Log) ToLogPayload() protocol.LogPayload {
731+
// ToLogPayload converts the Log to a protocol.LogItem for batching.
732+
func (l *Log) ToLogPayload() protocol.LogItem {
733733
attrs := make(map[string]protocol.LogAttribute, len(l.Attributes))
734734
for k, v := range l.Attributes {
735735
attrs[k] = protocol.LogAttribute{Value: v.Value, Type: string(v.Type)}
736736
}
737-
return protocol.LogPayload{
737+
return protocol.LogItem{
738738
Timestamp: l.Timestamp,
739739
TraceID: l.TraceID.String(),
740740
Level: string(l.Level),

internal/protocol/log_batch.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ type LogAttribute struct {
1313
Type string `json:"type"`
1414
}
1515

16-
// LogPayload represents the serialized shape of a single log record inside a batched
16+
// LogItem represents the serialized shape of a single log record inside a batched
1717
// log envelope item. Keep in sync with sentry.Log fields that are meant to be emitted.
18-
type LogPayload struct {
18+
type LogItem struct {
1919
Timestamp time.Time `json:"timestamp,omitempty"`
2020
TraceID string `json:"trace_id,omitempty"`
2121
Level string `json:"level"`
@@ -24,13 +24,13 @@ type LogPayload struct {
2424
Attributes map[string]LogAttribute `json:"attributes,omitempty"`
2525
}
2626

27-
// LogPayloader is implemented by items that can convert to a LogPayload for batching.
27+
// LogPayloader is implemented by items that can convert to a LogItem for batching.
2828
type LogPayloader interface {
29-
ToLogPayload() LogPayload
29+
ToLogPayload() LogItem
3030
}
3131

3232
// MarshalJSON encodes timestamp as seconds since epoch per Sentry logs spec.
33-
func (lp LogPayload) MarshalJSON() ([]byte, error) {
33+
func (lp LogItem) MarshalJSON() ([]byte, error) {
3434
// Convert time.Time to seconds float if set
3535
var ts *float64
3636
if !lp.Timestamp.IsZero() {
@@ -56,13 +56,13 @@ func (lp LogPayload) MarshalJSON() ([]byte, error) {
5656
return json.Marshal(out)
5757
}
5858

59-
// Logs is a container for multiple LogPayload items which knows how to convert
59+
// Logs is a container for multiple LogItem items which knows how to convert
6060
// itself into a single batched log envelope item.
61-
type Logs []LogPayload
61+
type Logs []LogItem
6262

6363
func (ls Logs) ToEnvelopeItem() (*EnvelopeItem, error) {
6464
wrapper := struct {
65-
Items []LogPayload `json:"items"`
65+
Items []LogItem `json:"items"`
6666
}{Items: ls}
6767

6868
payload, err := json.Marshal(wrapper)

internal/telemetry/scheduler.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -209,9 +209,9 @@ func (s *Scheduler) processItems(buffer BufferInterface[protocol.EnvelopeItemCon
209209

210210
switch category {
211211
case ratelimit.CategoryLog:
212-
envItems := make([]protocol.LogPayload, 0, len(items))
212+
envItems := make([]protocol.LogItem, 0, len(items))
213213
for _, it := range items {
214-
if lp, ok := any(it).(interface{ ToLogPayload() protocol.LogPayload }); ok {
214+
if lp, ok := any(it).(interface{ ToLogPayload() protocol.LogItem }); ok {
215215
envItems = append(envItems, lp.ToLogPayload())
216216
} else {
217217
debuglog.Printf("Invalid envelope item; cannot convert to log: %v", it)
@@ -243,7 +243,6 @@ func (s *Scheduler) processItems(buffer BufferInterface[protocol.EnvelopeItemCon
243243
s.sendItems(it)
244244
}
245245
}
246-
247246
}
248247

249248
func (s *Scheduler) sendItems(item protocol.EnvelopeItemConvertible) {

internal/telemetry/scheduler_test.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,13 @@ func (t *testTelemetryItem) GetDynamicSamplingContext() map[string]string {
5353
return nil
5454
}
5555

56+
func (t *testTelemetryItem) ToLogPayload() protocol.LogItem {
57+
return protocol.LogItem{
58+
Level: "info",
59+
Body: t.data,
60+
}
61+
}
62+
5663
func TestNewTelemetryScheduler(t *testing.T) {
5764
transport := &testutils.MockTelemetryTransport{}
5865
dsn := &protocol.Dsn{}
@@ -148,7 +155,7 @@ func TestTelemetrySchedulerFlush(t *testing.T) {
148155
i++
149156
}
150157
},
151-
expectedCount: 4,
158+
expectedCount: 3,
152159
},
153160
{
154161
name: "priority ordering - error and log",

0 commit comments

Comments
 (0)