mirror of
https://github.com/open-telemetry/opentelemetry-go.git
synced 2025-02-03 13:11:53 +02:00
dbe27d4147
* Replace Record lim methods with DroppedAttributes * Add changelog entry * Add TestRecordDroppedAttributes * Add TestRecordCompactAttr * Add an indexPool * Fix gramatical error * Apply feedback Reduce indentation level. * Apply feedback Comment compactAttr and deduplicate. * Deduplicate all attributes when added * Comment why head is not used * Clarify comments * Move TestAllocationLimits to new file Do not run this test when the race detector is on. * Comment follow-up task
61 lines
1.6 KiB
Go
61 lines
1.6 KiB
Go
// Copyright The OpenTelemetry Authors
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
package stdoutlog // import "go.opentelemetry.io/otel/exporters/stdout/stdoutlog"
|
|
|
|
import (
|
|
"time"
|
|
|
|
"go.opentelemetry.io/otel/log"
|
|
"go.opentelemetry.io/otel/sdk/instrumentation"
|
|
sdklog "go.opentelemetry.io/otel/sdk/log"
|
|
"go.opentelemetry.io/otel/sdk/resource"
|
|
"go.opentelemetry.io/otel/trace"
|
|
)
|
|
|
|
// recordJSON is a JSON-serializable representation of a Record.
|
|
type recordJSON struct {
|
|
Timestamp time.Time
|
|
ObservedTimestamp time.Time
|
|
Severity log.Severity
|
|
SeverityText string
|
|
Body log.Value
|
|
Attributes []log.KeyValue
|
|
TraceID trace.TraceID
|
|
SpanID trace.SpanID
|
|
TraceFlags trace.TraceFlags
|
|
Resource resource.Resource
|
|
Scope instrumentation.Scope
|
|
AttributeValueLengthLimit int
|
|
AttributeCountLimit int
|
|
}
|
|
|
|
func (e *Exporter) newRecordJSON(r sdklog.Record) recordJSON {
|
|
newRecord := recordJSON{
|
|
Severity: r.Severity(),
|
|
SeverityText: r.SeverityText(),
|
|
Body: r.Body(),
|
|
|
|
TraceID: r.TraceID(),
|
|
SpanID: r.SpanID(),
|
|
TraceFlags: r.TraceFlags(),
|
|
|
|
Attributes: make([]log.KeyValue, 0, r.AttributesLen()),
|
|
|
|
Resource: r.Resource(),
|
|
Scope: r.InstrumentationScope(),
|
|
}
|
|
|
|
r.WalkAttributes(func(kv log.KeyValue) bool {
|
|
newRecord.Attributes = append(newRecord.Attributes, kv)
|
|
return true
|
|
})
|
|
|
|
if e.timestamps {
|
|
newRecord.Timestamp = r.Timestamp()
|
|
newRecord.ObservedTimestamp = r.ObservedTimestamp()
|
|
}
|
|
|
|
return newRecord
|
|
}
|