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

io.opentelemetry.javaagent.bootstrap.http.HttpServerResponseCustomizerHolder Maven / Gradle / Ivy

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

package io.opentelemetry.javaagent.bootstrap.http;

import io.opentelemetry.context.Context;

/**
 * Holds the currently active response customizer. This is set during agent initialization to an
 * instance that calls each {@link HttpServerResponseCustomizer} found in the agent classpath. It is
 * intended to be used directly from HTTP server library instrumentations, which is why this package
 * is inside the bootstrap package that gets loaded in the bootstrap classloader.
 */
public final class HttpServerResponseCustomizerHolder {
  private static volatile HttpServerResponseCustomizer responseCustomizer = new NoOpCustomizer();

  public static void setCustomizer(HttpServerResponseCustomizer customizer) {
    HttpServerResponseCustomizerHolder.responseCustomizer = customizer;
  }

  public static HttpServerResponseCustomizer getCustomizer() {
    return responseCustomizer;
  }

  private HttpServerResponseCustomizerHolder() {}

  private static class NoOpCustomizer implements HttpServerResponseCustomizer {

    @Override
    public  void customize(
        Context serverContext, T response, HttpServerResponseMutator responseMutator) {}
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy