Source File
evictedqueue.go
Belonging Package
go.opentelemetry.io/otel/sdk/trace
// Copyright The OpenTelemetry Authors// SPDX-License-Identifier: Apache-2.0package trace // import "go.opentelemetry.io/otel/sdk/trace"import ()// evictedQueue is a FIFO queue with a configurable capacity.type evictedQueue[ any] struct {queue []capacity intdroppedCount intlogDroppedMsg stringlogDroppedOnce sync.Once}func newEvictedQueueEvent( int) evictedQueue[Event] {// Do not pre-allocate queue, do this lazily.return evictedQueue[Event]{capacity: ,logDroppedMsg: "limit reached: dropping trace trace.Event",}}func newEvictedQueueLink( int) evictedQueue[Link] {// Do not pre-allocate queue, do this lazily.return evictedQueue[Link]{capacity: ,logDroppedMsg: "limit reached: dropping trace trace.Link",}}// add adds value to the evictedQueue eq. If eq is at capacity, the oldest// queued value will be discarded and the drop count incremented.func ( *evictedQueue[]) ( ) {if .capacity == 0 {.droppedCount++.logDropped()return}if .capacity > 0 && len(.queue) == .capacity {// Drop first-in while avoiding allocating more capacity to eq.queue.copy(.queue[:.capacity-1], .queue[1:]).queue = .queue[:.capacity-1].droppedCount++.logDropped()}.queue = append(.queue, )}func ( *evictedQueue[]) () {.logDroppedOnce.Do(func() { global.Warn(.logDroppedMsg) })}// copy returns a copy of the evictedQueue.func ( *evictedQueue[]) () [] {return slices.Clone(.queue)}
![]() |
The pages are generated with Golds v0.8.2. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |