| 1 |
// Copyright The OpenTelemetry Authors |
| 2 |
// SPDX-License-Identifier: Apache-2.0 |
| 3 |
|
| 4 |
package plog // import "go.opentelemetry.io/collector/pdata/plog" |
| 5 |
|
| 6 |
// MarkReadOnly marks the Logs as shared so that no further modifications can be done on it. |
| 7 |
func (ms Logs) MarkReadOnly() { |
| 8 |
ms.getState().MarkReadOnly() |
| 9 |
} |
| 10 |
|
| 11 |
// IsReadOnly returns true if this Logs instance is read-only. |
| 12 |
func (ms Logs) IsReadOnly() bool { |
| 13 |
return ms.getState().IsReadOnly() |
| 14 |
} |
| 15 |
|
| 16 |
// LogRecordCount calculates the total number of log records. |
| 17 |
func (ms Logs) LogRecordCount() int { |
| 18 |
logCount := 0 |
| 19 |
rss := ms.ResourceLogs() |
| 20 |
for i := 0; i < rss.Len(); i++ { |
| 21 |
rs := rss.At(i) |
| 22 |
ill := rs.ScopeLogs() |
| 23 |
for i := 0; i < ill.Len(); i++ { |
| 24 |
logs := ill.At(i) |
| 25 |
logCount += logs.LogRecords().Len() |
| 26 |
} |
| 27 |
} |
| 28 |
return logCount |
| 29 |
} |