def METHOD_NAME(request, flask_app, sending_elasticapm_client):
    client_config = getattr(request, "param", {})
    client_config.setdefault("app", flask_app)
    client_config.setdefault("client", sending_elasticapm_client)
    client = ElasticAPM(**client_config)
    try:
        yield client
    finally:
        elasticapm.uninstrument()
        signals.request_started.disconnect(client.request_started)
        signals.request_finished.disconnect(client.request_finished)
        # remove logging handler if it was added
        logger = logging.getLogger()
        for handler in list(logger.handlers):
            if getattr(handler, "client", None) is client.client:
                logger.removeHandler(handler)