All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.opentelemetry.instrumentation.kafka.internal.MetricsReporterList Maven / Gradle / Ivy

There is a newer version: 2.9.0-alpha
Show newest version
/*
 * Copyright The OpenTelemetry Authors
 * SPDX-License-Identifier: Apache-2.0
 */

package io.opentelemetry.instrumentation.kafka.internal;

import java.util.ArrayList;
import java.util.List;

/**
 * List implementation that can be used to hold metrics reporters in kafka configuration without
 * breaking serialization. When this list is serialized it removes OpenTelemetryMetricsReporter to
 * ensure that the configuration can be deserialized even when the instrumentation is not present.
 *
 * 

This class is internal and is hence not for public use. Its APIs are unstable and can change * at any time. */ public class MetricsReporterList extends ArrayList { private static final long serialVersionUID = 1L; public static List singletonList(T o) { List list = new MetricsReporterList<>(); list.add(o); return list; } private Object writeReplace() { // serialize to plain ArrayList that does not contain OpenTelemetryMetricsReporter List result = new ArrayList<>(); this.stream().filter(x -> x != OpenTelemetryMetricsReporter.class).forEach(result::add); return result; } }