io.opentelemetry.sdk.logs.ReadWriteLogRecord Maven / Gradle / Ivy
The newest version!
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/
package io.opentelemetry.sdk.logs;
import io.opentelemetry.api.common.AttributeKey;
import io.opentelemetry.api.common.Attributes;
import io.opentelemetry.sdk.logs.data.LogRecordData;
/**
* A log record that can be read from and written to.
*
* @since 1.27.0
*/
public interface ReadWriteLogRecord {
/**
* Sets an attribute on the log record. If the log record previously contained a mapping for the
* key, the old value is replaced by the specified value.
*
* Note: the behavior of null values is undefined, and hence strongly discouraged.
*/
ReadWriteLogRecord setAttribute(AttributeKey key, T value);
// TODO: add additional setters
/**
* Sets attributes to the {@link ReadWriteLogRecord}. If the {@link ReadWriteLogRecord} previously
* contained a mapping for any of the keys, the old values are replaced by the specified values.
*
* @param attributes the attributes
* @return this.
* @since 1.31.0
*/
@SuppressWarnings("unchecked")
default ReadWriteLogRecord setAllAttributes(Attributes attributes) {
if (attributes == null || attributes.isEmpty()) {
return this;
}
attributes.forEach(
(attributeKey, value) -> this.setAttribute((AttributeKey