Skip to content

Commit c4ebcaa

Browse files
authored
Ensure exported struct in sdk/log are not comparable (#5693)
Ensure the `Record` and `Provider` continue to be non-comparable. Restrict `BatchProcessor` and `SimpleProcessor` to be non-comparable. There is no obvious reason an end-user will need to compare these types, and we want to keep the possibility of changing the internals without changing this behavior. if comparability is required by end-users in the future we can add `Equal(other T)` methods in the future.
1 parent 69e2358 commit c4ebcaa

File tree

5 files changed

+10
-0
lines changed

5 files changed

+10
-0
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
2424
- `SimpleProcessor.Enabled` in `go.opentelemetry.io/otel/sdk/log` now returns `false` if the exporter is `nil`. (#5665)
2525
- Update the concurrency requirements of `Exporter` in `go.opentelemetry.io/otel/sdk/log`. (#5666)
2626
- `SimpleProcessor` in `go.opentelemetry.io/otel/sdk/log` synchronizes `OnEmit` calls. (#5666)
27+
- The `SimpleProcessor` type in `go.opentelemetry.io/otel/sdk/log` is no longer comparable. (#5693)
28+
- The `BatchProcessor` type in `go.opentelemetry.io/otel/sdk/log` is no longer comparable. (#5693)
2729

2830
### Fixed
2931

sdk/log/batch.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ type BatchProcessor struct {
9696

9797
// stopped holds the stopped state of the BatchProcessor.
9898
stopped atomic.Bool
99+
100+
noCmp [0]func() //nolint: unused // This is indeed used.
99101
}
100102

101103
// NewBatchProcessor decorates the provided exporter

sdk/log/provider.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ type LoggerProvider struct {
6969
loggers map[instrumentation.Scope]*logger
7070

7171
stopped atomic.Bool
72+
73+
noCmp [0]func() //nolint: unused // This is indeed used.
7274
}
7375

7476
// Compile-time check LoggerProvider implements log.LoggerProvider.

sdk/log/record.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ type Record struct {
8686

8787
attributeValueLengthLimit int
8888
attributeCountLimit int
89+
90+
noCmp [0]func() //nolint: unused // This is indeed used.
8991
}
9092

9193
func (r *Record) addDropped(n int) {

sdk/log/simple.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ var _ Processor = (*SimpleProcessor)(nil)
1717
type SimpleProcessor struct {
1818
mu sync.Mutex
1919
exporter Exporter
20+
21+
noCmp [0]func() //nolint: unused // This is indeed used.
2022
}
2123

2224
// NewSimpleProcessor is a simple Processor adapter.

0 commit comments

Comments
 (0)