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

com.feedzai.commons.tracing.engine.NoopTracingEngine Maven / Gradle / Ivy

There is a newer version: 0.1.17
Show newest version
/*
 * Copyright 2018 Feedzai
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * 	http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.feedzai.commons.tracing.engine;import com.feedzai.commons.tracing.api.Promise;
import com.feedzai.commons.tracing.api.TraceContext;
import io.opentracing.Span;
import io.opentracing.Tracer;
import io.opentracing.noop.NoopSpan;
import io.opentracing.noop.NoopTracerFactory;

import java.io.Serializable;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
import java.util.function.Supplier;

/**
 * Implementation of all Tracing APIs that does nothing so as not to affect the execution of the application.
 *
 * @author Gonçalo Garcia ([email protected])
 */
public class NoopTracingEngine implements TracingEngine {

    /**
     * Null trace context to be used wherever is needed, since the logs won't take into account the causality between
     * calls.
     */
    public static final TraceContext TRACE_CONTEXT = new TraceContext() {
        @Override
        public Object get() {
            return null;
        }
    };

    @Override
    public 

, R> P addToTraceOpenPromise(Supplier

toTraceAsync, Object object, String description) { return toTraceAsync.get(); } @Override public CompletableFuture addToTraceOpenFuture(Supplier> toTraceAsync, Object object, String description) { return toTraceAsync.get(); } @Override public void addToTraceOpen(Runnable toTraceAsync, Object object, String description) { toTraceAsync.run(); } @Override public R addToTraceOpen(Supplier toTraceAsync, Object value, String description) { return toTraceAsync.get(); } @Override public

, R> P addToTraceOpenPromise(Supplier

toTraceAsync, Object object, String description, String eventId) { return toTraceAsync.get(); } @Override public CompletableFuture addToTraceOpenFuture(Supplier> toTraceAsync, Object object, String description, String eventId) { return toTraceAsync.get(); } @Override public void addToTraceOpen(Runnable toTraceAsync, Object object, String description, String eventId) { toTraceAsync.run(); } @Override public R addToTraceOpen(Supplier toTraceAsync, Object value, String description, String eventId) { return toTraceAsync.get(); } @Override public void closeOpen(Object object) { } @Override public

, R> P addToTraceOpenPromise(Supplier

toTraceAsync, Object object, String description, TraceContext context) { return toTraceAsync.get(); } @Override public CompletableFuture addToTraceOpenFuture(Supplier> toTraceAsync, Object object, String description, TraceContext context) { return toTraceAsync.get(); } @Override public void addToTraceOpen(Runnable toTraceAsync, Object object, String description, TraceContext context) { toTraceAsync.run(); } @Override public R addToTraceOpen(Supplier toTraceAsync, Object value, String description, TraceContext context) { return toTraceAsync.get(); } @Override public R newProcess(Supplier toTrace, String description, TraceContext context) { return toTrace.get(); } @Override public void newProcess(Runnable toTrace, String description, TraceContext context) { toTrace.run(); } @Override public

, R> P newProcessPromise(Supplier

toTrace, String description, TraceContext context) { return toTrace.get(); } @Override public CompletableFuture newProcessFuture(Supplier> toTrace, String description, TraceContext context) { return toTrace.get(); } @Override public R addToTrace(Supplier toTrace, String description, TraceContext context) { return toTrace.get(); } @Override public void addToTrace(Runnable toTrace, String description, TraceContext context) { toTrace.run(); } @Override public CompletableFuture addToTraceAsync(Supplier> toTraceAsync, String description, TraceContext context) { return toTraceAsync.get(); } @Override public

, R> P addToTracePromise(Supplier

toTraceAsync, String description, TraceContext context) { return toTraceAsync.get(); } @Override public Map serializeContext() { return new HashMap<>(); } @Override public TraceContext deserializeContext(final Map headers) { return TRACE_CONTEXT; } @Override public TraceContext currentContext() { return TRACE_CONTEXT; } @Override public TraceContext currentContextforObject(Object obj) { return TRACE_CONTEXT; } @Override public R newTrace(Supplier toTrace, String description) { return toTrace.get(); } @Override public void newTrace(Runnable toTrace, String description) { toTrace.run(); } @Override public CompletableFuture newTraceAsync(Supplier> toTraceAsync, String description) { return toTraceAsync.get(); } @Override public

, R> P newTracePromise(Supplier

toTraceAsync, String description) { return toTraceAsync.get(); } @Override public R addToTrace(Supplier toTrace, String description) { return toTrace.get(); } @Override public void addToTrace(Runnable toTrace, String description) { toTrace.run(); } @Override public CompletableFuture addToTraceAsync(Supplier> toTraceAsync, String description) { return toTraceAsync.get(); } @Override public

, R> P addToTracePromise(Supplier

toTraceAsync, String description) { return toTraceAsync.get(); } @Override public boolean isActive() { return false; } @Override public R newTrace(Supplier toTrace, String description, String eventId) { return toTrace.get(); } @Override public void newTrace(Runnable toTrace, String description, String eventId) { toTrace.run(); } @Override public CompletableFuture newTraceAsync(Supplier> toTraceAsync, String description, String eventId) { return toTraceAsync.get(); } @Override public

, R> P newTracePromise(Supplier

toTraceAsync, String description, String eventId) { return toTraceAsync.get(); } @Override public R newProcess(Supplier toTrace, String description, String eventId) { return toTrace.get(); } @Override public void newProcess(Runnable toTrace, String description, String eventId) { toTrace.run(); } @Override public CompletableFuture newProcessFuture(Supplier> toTrace, String description, String eventId) { return toTrace.get(); } @Override public

, R> P newProcessPromise(Supplier

toTrace, String description, String eventId) { return toTrace.get(); } @Override public R addToTrace(Supplier toTrace, String description, String eventId) { return toTrace.get(); } @Override public void addToTrace(Runnable toTrace, String description, String eventId) { toTrace.run(); } @Override public CompletableFuture addToTraceAsync(Supplier> toTraceAsync, String description, String eventId) { return toTraceAsync.get(); } @Override public

, R> P addToTracePromise(Supplier

toTraceAsync, String description, String eventId) { return toTraceAsync.get(); } @Override public TraceContext currentContextforId(String eventId) { return TRACE_CONTEXT; } @Override public boolean traceHasStarted(String eventId) { return false; } @Override public Tracer getTracer() { return NoopTracerFactory.create(); } @Override public Span currentSpan() { return NoopSpan.INSTANCE; } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy