com.uber.jaeger.senders.InMemorySender Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jaeger-core Show documentation
Show all versions of jaeger-core Show documentation
Jaeger Java bindings for OpenTracing API
/*
* Copyright (c) 2016, Uber Technologies, Inc
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.uber.jaeger.senders;
import com.twitter.zipkin.thriftjava.Span;
import com.uber.jaeger.exceptions.SenderException;
import java.util.ArrayList;
import java.util.List;
public class InMemorySender implements Sender {
private List appended;
private List flushed;
private List received;
public InMemorySender() {
appended = new ArrayList<>();
flushed = new ArrayList<>();
received = new ArrayList<>();
}
public List getAppended() {
return new ArrayList<>(appended);
}
public List getFlushed() {
return new ArrayList<>(flushed);
}
public List getReceived() {
return new ArrayList<>(received);
}
@Override
public int append(Span span) throws SenderException {
appended.add(span);
received.add(span);
return 0;
}
@Override
public int flush() throws SenderException {
int flushedSpans = appended.size();
flushed.addAll(appended);
appended.clear();
return flushedSpans;
}
@Override
public int close() throws SenderException {
return flush();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy